drg_resources_plugin 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 82e107f96a1a35c8513033e2f42a806747860ac4
4
+ data.tar.gz: d86ef816c91c546495c853a882486cefeffc8aec
5
+ SHA512:
6
+ metadata.gz: bae22f69c567c280f849f327986f882a4a57ee1213203cfb74050e9ad89e4e34f4f30263518f5b78cb85a1cae175e7b49bbd2a62a778e84065f4c0cb95f0ecf5
7
+ data.tar.gz: 94cbd3d17b92f842413fff67fa82f463cc667f473b7229a73e29e7c862ece46db6b03720ac89b911fd604c3c01dfc96e1c43f9bd847dc26e228809786e067a1e
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2018 Damjan Rems
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+
2
+ # DrgResourcesPlugin
3
+ This is DRG CMS plugin which can be used for internal resources reservation. I am using it for keeping record of company autopark, but it can be used for any kind of resource reservation.
4
+ Resorces have category field, to distinct different kind of resources. Resources categories must be defined in Big Table under 'resource-categories' key.
5
+
6
+ ## Usage
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'drg_resources_plugin'
11
+ ```
12
+ and run bundle to add new gem to application.
13
+
14
+ Create page with resources link, set design to Portal design and set site to your portal name.
15
+ Create new top menu option in site menu and link it to Resources page.
16
+
17
+ Refresh browser and click Resources menu option.
18
+
19
+ ## Contributing
20
+ Fork this repository on GitHub and issue a pull request
21
+
22
+ ## License
23
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,36 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'DrgResourcesPlugin'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ require 'bundler/gem_tasks'
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'test'
31
+ t.pattern = 'test/**/*_test.rb'
32
+ t.verbose = false
33
+ end
34
+
35
+
36
+ task default: :test
@@ -0,0 +1,25 @@
1
+
2
+ $(document).ready(function() {
3
+ /**********************************************************************
4
+ * Resources: Update resource usage panel when selected_date changes
5
+ **********************************************************************/
6
+ $('#record_selected_date').bind('change', function() {
7
+ var category = $('#category').val();
8
+ window.location.href = '/resources?selected_date=' + this.value + '&category=' + category;
9
+ });
10
+
11
+ /**********************************************************************
12
+ * Resources: Update resource usage panel when categorychanges
13
+ **********************************************************************/
14
+ $('#category').bind('change', function() {
15
+ window.location.href = '/resources?category=' + this.value;
16
+ });
17
+
18
+ /*******************************************************************
19
+ * Popup CMS edit menu option clicked
20
+ *******************************************************************/
21
+ $('.resources-table .usage div').on('click',function(e) {
22
+ var url = e.target.getAttribute("data-url");
23
+ $('#iframe_edit').attr('src', url);
24
+ });
25
+ });
@@ -0,0 +1,73 @@
1
+ .action-menu {
2
+ margin: 0;
3
+ }
4
+ .action-menu li {
5
+ display: inline;
6
+ position: relative;
7
+ list-style: none;
8
+ margin-right: 4px;
9
+ }
10
+
11
+ .resources_menu #record_selected_date {
12
+ width: 120px;
13
+ height: 2rem;
14
+ display: inline;
15
+ margin-bottom: 0;
16
+ }
17
+
18
+ .resources_menu #category {
19
+ width: 120px;
20
+ height:inherit;
21
+ font-size: 1.2em;
22
+ padding: 4px 0px;
23
+ display: inline;
24
+ margin: 0 0 0 6px;
25
+ }
26
+
27
+ .resources-table .th {
28
+ width: 12%;
29
+ border: 1px solid #ccc;
30
+ border-right: none;
31
+ padding: 4px;
32
+ text-align: center;
33
+ font-weight: bold;
34
+ background-color: #ccc;
35
+ }
36
+ .resources-table .td {
37
+ width: 12%;
38
+ border: 1px solid #ccc;
39
+ border-top: none;
40
+ border-right: none;
41
+ min-height: 50px;
42
+ vertical-align: central;
43
+ padding: 2px 0;
44
+ }
45
+
46
+ .resources-table .th.name, .resources-table .td.name {
47
+ width: 16%;
48
+ font-weight: bold;
49
+
50
+ }
51
+
52
+ .resources-table .td.name {
53
+ background-color: #ffe;
54
+ }
55
+
56
+ .resources-table .td div {
57
+ background-color: #eee;
58
+ padding: 2px;
59
+ border-top: 1px solid #ddd;
60
+ border-bottom: 1px solid #ddd;
61
+ margin: 2px 0;
62
+ white-space: nowrap;
63
+ overflow: hidden;
64
+ text-overflow: ellipsis;
65
+ }
66
+
67
+ .resources-table .td div:hover {
68
+ cursor: pointer;
69
+ }
70
+
71
+ .resources-table {
72
+ border-right: 1px solid #ccc;
73
+ }
@@ -0,0 +1,58 @@
1
+ #encoding: utf-8
2
+ #--
3
+ # Copyright (c) 2014+ Damjan Rems
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ #++
24
+
25
+ module DrgcmsControls::ResourceUsageControl
26
+
27
+ ######################################################################
28
+ # Called when new reservation is created.
29
+ ######################################################################
30
+ def dc_new_record()
31
+ unless ( dc_user_has_role('resources-reservation') or dc_user_has_role('admin') )
32
+ flash[:error] = 'No permission for adding reservations!'
33
+ return false
34
+ end
35
+ @record.resource_id = params[:resource_id]
36
+ @record.dc_user_id = session[:user_id]
37
+ @record.time_from = params[:current_date]
38
+ @record.time_to = params[:current_date]
39
+ end
40
+
41
+ ######################################################################
42
+ # check if it's OK to delete reservation document.
43
+ ######################################################################
44
+ def can_delete_resource()
45
+ # reservation's time is up
46
+ if @record.time_to < Time.now
47
+ flash[:error] = 'Time is up. Deleting is meaningless!'
48
+ return false
49
+ end
50
+ # not everyone can delete reservation
51
+ unless (@record.dc_user_id == session[:user_id] or dc_user_has_role('admin') )
52
+ flash[:error] = 'Only owner or administrator can delete document!'
53
+ return false
54
+ end
55
+ end
56
+
57
+ end
58
+
@@ -0,0 +1,53 @@
1
+ ## DRG Form
2
+ table: resource
3
+
4
+ index:
5
+ filter: id as text_field, name
6
+ actions: standard
7
+
8
+ result_set:
9
+ actions: standard
10
+
11
+ # actions:
12
+ # 1:
13
+ # type: link
14
+ # controller: controller_name
15
+ # action: action_name
16
+ # table: table_name
17
+ # form_name: form_name
18
+ # target: target
19
+ # method: (get),put,post
20
+ columns:
21
+ 10:
22
+ name: name
23
+ 20:
24
+ name: category
25
+ 30:
26
+ name: description
27
+ width: 60%
28
+ 40:
29
+ name: active
30
+ eval: dc_icon4_boolean
31
+
32
+ form:
33
+ title:
34
+ field: name
35
+ actions: standard
36
+
37
+ fields:
38
+ 10:
39
+ name: name
40
+ type: text_field
41
+ size: 30
42
+ 20:
43
+ name: description
44
+ type: text_field
45
+ size: 70
46
+ 30:
47
+ name: category
48
+ type: select
49
+ eval: dc_big_table 'resource-categories'
50
+ 40:
51
+ name: active
52
+ type: check_box
53
+
@@ -0,0 +1,43 @@
1
+ ## DRG Form
2
+ ---
3
+ table: resource_usage
4
+ title: Create new resource reservation
5
+
6
+ form:
7
+ actions:
8
+ 1:
9
+ type: script
10
+ caption: Back
11
+ js: parent.location.href=parent.location.href
12
+ 5:
13
+ type: submit
14
+ caption: Save
15
+ params:
16
+ after-save: return_to parent.reload
17
+
18
+ fields:
19
+ 10:
20
+ name: resource_id
21
+ type: readonly
22
+ eval: dc_name4_id,resource,name
23
+ 20:
24
+ name: description
25
+ type: text_field
26
+ html:
27
+ size: 50
28
+ 30:
29
+ name: time_from
30
+ type: datetime_picker
31
+ options:
32
+ step: 30
33
+ 40:
34
+ name: time_to
35
+ type: datetime_picker
36
+ options:
37
+ step: 30
38
+ # for displaying created by name
39
+ 50:
40
+ name: dc_user_id
41
+ type: readonly
42
+ eval: dc_name4_id,dc_user,name
43
+
@@ -0,0 +1,14 @@
1
+ ## DRG Form
2
+ ---
3
+ extend: resource_usage
4
+ title: Resource reservation
5
+
6
+ form:
7
+ actions:
8
+ 5:
9
+ type: delete
10
+ caption: Delete reservation
11
+ params:
12
+ before-delete: can_delete_resource
13
+ after-delete: return_to parent.reload
14
+
@@ -0,0 +1,21 @@
1
+ module ResourcesHelper
2
+
3
+ #####################################################################
4
+ #
5
+ #####################################################################
6
+ def render_usages(resource_usages, date)
7
+ html = ''
8
+ return html if resource_usages.nil?
9
+ resource_usages.each do |usage|
10
+ if usage.time_from <= date.end_of_day and usage.time_to >= date.beginning_of_day
11
+ time1 = usage.time_from < date.beginning_of_day ? '00:00' : usage.time_from.strftime('%H:%M')
12
+ time2 = usage.time_to > date.end_of_day ? '24:00' : usage.time_to.strftime('%H:%M')
13
+ next if time1 == time2
14
+ url = "/cms/#{usage.id}/edit?form_name=resource_usage_show&table=resource_usage"
15
+ html << %Q[<div title="Click to view" data-url="#{url}"><b>#{time1} - #{time2}</b><br>#{usage.description}</div>]
16
+ end
17
+ end
18
+ html.html_safe
19
+ end
20
+
21
+ end
@@ -0,0 +1,58 @@
1
+ #--
2
+ # Copyright (c) 2014+ Damjan Rems
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ ########################################################################
25
+ #
26
+ ########################################################################
27
+ class ResourcesRenderer < DcRenderer
28
+ include DcApplicationHelper
29
+
30
+ ########################################################################
31
+ #
32
+ ########################################################################
33
+ def resources_usage
34
+ time = Date.parse(@parent.params[:selected_date]) rescue DateTime.now
35
+ date_from = time.beginning_of_week
36
+ date_to = time.end_of_week
37
+
38
+ resources = Resource.where(category: @parent.params[:category], active: true).order_by(name: 1).to_a
39
+ ids = resources.inject([]) { |r,e| r << e.id }
40
+ usages = ResourceUsage.where(:resource_id.in => ids)
41
+ .and(:time_from.lt => date_to, :time_to.gt => date_from)
42
+ .order_by(resource_id: 1, time_from: 1).group_by(&:resource_id)
43
+ #
44
+ @parent.render(partial: 'resources/usage', formats: [:html],
45
+ locals: { date_from: date_from, date_to: date_to,
46
+ resources: resources, usages: usages })
47
+ end
48
+
49
+ ########################################################################
50
+ # default renderer method will render application menu and usage table below.
51
+ ########################################################################
52
+ def default
53
+ html = @parent.render(partial: 'resources/menu', formats: [:html], locals: { parent: @parent })
54
+ html << dc_flash_messages
55
+ html << resources_usage#.html_safe
56
+ end
57
+
58
+ end
@@ -0,0 +1,58 @@
1
+ #--
2
+ # Copyright (c) 2018+ Damjan Rems
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ ##########################################################################
25
+ # Resources declaration collection
26
+ #
27
+ # == Schema information
28
+ #
29
+ # Collection name: resource : Available resources
30
+ #
31
+ # _id BSON::ObjectId _id
32
+ # created_at Time Created at time
33
+ # updated_at Time Last updated at time
34
+ # name String Resource name
35
+ # description String Description of the resource
36
+ # category BSON::ObjectId Resource category
37
+ # active Boolean Resource is active
38
+ ##########################################################################
39
+ class Resource
40
+ include Mongoid::Document
41
+ include Mongoid::Timestamps
42
+
43
+ field :name, type: String
44
+ field :description, type: String
45
+ field :category, type: BSON::ObjectId
46
+ field :active, type: Boolean, default: true
47
+
48
+ field :created_by, type: BSON::ObjectId
49
+ field :updated_by, type: BSON::ObjectId
50
+
51
+ index category: 1
52
+
53
+ validates :name, presence: true
54
+ validates :description, presence: true
55
+ validates :category, presence: true
56
+
57
+ has_many :resource_usages
58
+ end
@@ -0,0 +1,79 @@
1
+ #encoding: utf-8
2
+ #--
3
+ # Copyright (c) 2018+ Damjan Rems
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ #++
24
+
25
+ ##########################################################################
26
+ # Resources usage (reservation) collection
27
+ #
28
+ # == Schema information
29
+ #
30
+ # Collection name: resource : Available resources
31
+ #
32
+ # _id BSON::ObjectId _id
33
+ # created_at Time Created at time
34
+ # updated_at Time Last updated at time
35
+ # time_from DateTime Reservation start time
36
+ # time_to DateTime Reservation end time
37
+ # description String Description of the reservation
38
+ # resource_id BSON::ObjectId Resource id
39
+ # dc_user_id BSON::ObjectId Reservation was created by
40
+ # active Boolean Resource is active
41
+ ##########################################################################
42
+ class ResourceUsage
43
+ include Mongoid::Document
44
+ include Mongoid::Timestamps
45
+
46
+ field :time_from, type: DateTime
47
+ field :time_to, type: DateTime
48
+ field :description, type: String
49
+
50
+ field :created_by, type: BSON::ObjectId
51
+ field :updated_by, type: BSON::ObjectId
52
+
53
+ belongs_to :resource
54
+ belongs_to :dc_user
55
+
56
+ index resource_id: 1
57
+
58
+ validates :time_from, presence: true
59
+ validates :time_to, presence: true
60
+ validates :description, presence: true
61
+
62
+ validate :free_time_validations
63
+
64
+ ######################################################################
65
+ # Validates if resource is available in specified time window.
66
+ ######################################################################
67
+ def free_time_validations
68
+ errors.add(:time_from, "should be less then end time!") if time_from >= time_to
69
+ errors.add(:time_from, "is less then current time!") if time_from <= Time.now
70
+ if ResourceUsage.where(resource_id: resource_id).and({"$or" => [
71
+ {"$and" => [ {:time_from.lt => time_from}, {:time_to.gt => time_from} ] },
72
+ {"$and" => [ {:time_from.lt => time_to}, {:time_to.gt => time_to} ] },
73
+ {"$and" => [ {:time_from.gte => time_from}, {:time_to.lte => time_to} ] }
74
+ ] }).exists?
75
+ errors.add(:time_from, "Resource already taken!")
76
+ end
77
+ end
78
+
79
+ end
@@ -0,0 +1,21 @@
1
+ <!-- Create DRG CMS field in the view -->
2
+ <%
3
+ form = {'name' => 'selected_date', 'html' => { 'value' => params[:selected_date], 'placeholder' => 'Select week' }}
4
+ date_picker = DrgcmsFormFields::DatePicker.new(parent, {}, form).render
5
+ %>
6
+
7
+ <ul class="action-menu resources_menu">
8
+ <li>
9
+ <%= date_picker.html.html_safe %>
10
+ <%= select(nil, 'category', DcBigTable.choices4('resource-categories', nil), { selected: params[:category]} ) %>
11
+ </li>
12
+
13
+ <li class="dc-link dc-animate">
14
+ <%= dc_link_to 'Resources', 'table', {controller: 'cmsedit', table: 'resource'}, target: 'iframe_edit' %>
15
+ </li>
16
+ </ul>
17
+
18
+ <%= javascript_tag(date_picker.js) %>
19
+ <hr class='hr-separator'>
20
+
21
+ <%= dc_iframe_edit(nil) %>
@@ -0,0 +1,30 @@
1
+
2
+ <div class='resources-table' width='99%'>
3
+ <div class="row date">
4
+ <div class="th name"></div>
5
+ <%# date = date_from; while date < date_to %>
6
+ <% date_from.step(date_to, 1) do |date| %>
7
+ <div class="th">
8
+ <%= I18n.t('date.day_names')[date.wday] %><br/><%= date.strftime('%d.%m.') %>
9
+ </div>
10
+ <% end %>
11
+ </div>
12
+
13
+ <div class="row resource">
14
+ <% for resource in resources %>
15
+ <div class="td name">
16
+ <%= resource.name %>
17
+ </div>
18
+ <% date_from.step(date_to, 1) do |date| %>
19
+ <div class="td usage">
20
+ <%= dc_link_to(nil, 'plus-square lg', { title: 'New reservation',
21
+ controller: :cmsedit, action: :new, target: :iframe_edit,
22
+ table: :resource_usage, resource_id: resource.id,
23
+ current_date: date.to_s}, {class: 'dc-link-img'} )
24
+ %>
25
+ <%= render_usages(usages[resource.id], date) %>
26
+ </div>
27
+ <% end %>
28
+ <% end %>
29
+ </div>
30
+ </div>
@@ -0,0 +1,52 @@
1
+ #--
2
+ # Copyright (c) 2018+ Damjan Rems
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ #################################################################
25
+ # Localization
26
+ en:
27
+ helpers:
28
+ label:
29
+ resource:
30
+ tabletitle: Resources
31
+
32
+ name: Name
33
+ description: Description
34
+ category: Category
35
+ active: Active
36
+
37
+ resource_usage:
38
+ tabletitle: Resource reservation
39
+
40
+ resource_id: Resource name
41
+ description: Description
42
+ time_from: Reserved from
43
+ time_to: Reserved to
44
+ dc_user_id: Created by
45
+
46
+ help:
47
+ resource:
48
+ name: Resource name
49
+ description: Short resource description
50
+ category: Resource category. Define categories under resources-categories key in BigTable.
51
+ active: Resource is active
52
+
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ Rails.application.routes.draw do
2
+ end
@@ -0,0 +1,7 @@
1
+ require "drg_resources_plugin/engine"
2
+
3
+ module DrgResourcesPlugin
4
+ # Your code goes here...
5
+ end
6
+
7
+ DrgCms.add_forms_path File.expand_path("../../app/forms", __FILE__)
@@ -0,0 +1,4 @@
1
+ module DrgResourcesPlugin
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module DrgResourcesPlugin
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :drg_resources_plugin do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: drg_resources_plugin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Damjan Rems
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-10-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: drg_cms
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: This is DRG CMS plugin which can be used for internal resources reservation.
42
+ I am using it for keeping record of company autopark.
43
+ email:
44
+ - damjan.rems@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - MIT-LICENSE
50
+ - README.md
51
+ - Rakefile
52
+ - app/assets/config/drg_resources_plugin_manifest.js
53
+ - app/assets/javascripts/resources.js
54
+ - app/assets/stylesheets/resources.css
55
+ - app/controllers/drgcms_controls/resource_usage_control.rb
56
+ - app/forms/resource.yml
57
+ - app/forms/resource_usage.yml
58
+ - app/forms/resource_usage_show.yml
59
+ - app/helpers/resources_helper.rb
60
+ - app/helpers/resources_renderer.rb
61
+ - app/models/resource.rb
62
+ - app/models/resource_usage.rb
63
+ - app/views/resources/_menu.html.erb
64
+ - app/views/resources/_usage.html.erb
65
+ - config/locales/resources_en.yml
66
+ - config/routes.rb
67
+ - lib/drg_resources_plugin.rb
68
+ - lib/drg_resources_plugin/engine.rb
69
+ - lib/drg_resources_plugin/version.rb
70
+ - lib/tasks/drg_resources_plugin_tasks.rake
71
+ homepage: https://www.drgcms.org
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.6.14.1
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: DRG CMS portal plugin for resource reservation
95
+ test_files: []