drg_resources_plugin 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82e107f96a1a35c8513033e2f42a806747860ac4
4
- data.tar.gz: d86ef816c91c546495c853a882486cefeffc8aec
3
+ metadata.gz: d2c1e8d33e4a9cd415707a89a02816b309b668ae
4
+ data.tar.gz: cef952b2ddebb29d63ba2a3020d575d9bd6e41bf
5
5
  SHA512:
6
- metadata.gz: bae22f69c567c280f849f327986f882a4a57ee1213203cfb74050e9ad89e4e34f4f30263518f5b78cb85a1cae175e7b49bbd2a62a778e84065f4c0cb95f0ecf5
7
- data.tar.gz: 94cbd3d17b92f842413fff67fa82f463cc667f473b7229a73e29e7c862ece46db6b03720ac89b911fd604c3c01dfc96e1c43f9bd847dc26e228809786e067a1e
6
+ metadata.gz: 33df0ef9c4dfab0962b4dd83a28aba1da340b7fd342e6a35151b0748ec9b789358c5dac6c877765f8cb7565d5a32b076e1e638d058e33f9760a18120f618ae1f
7
+ data.tar.gz: 1f9ac0d09f18cc34f5dbaaa494cdf1135fa7fee3b2428301cdfb054937076424ce18fdb8500883793c819741f54bb17660b1aac5e3991028bf633334169ba5d2
@@ -1,3 +1,25 @@
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
+ */
1
23
 
2
24
  $(document).ready(function() {
3
25
  /**********************************************************************
@@ -40,7 +40,7 @@
40
40
  border-right: none;
41
41
  min-height: 50px;
42
42
  vertical-align: central;
43
- padding: 2px 0;
43
+ padding: 0;
44
44
  }
45
45
 
46
46
  .resources-table .th.name, .resources-table .td.name {
@@ -57,8 +57,7 @@
57
57
  background-color: #eee;
58
58
  padding: 2px;
59
59
  border-top: 1px solid #ddd;
60
- border-bottom: 1px solid #ddd;
61
- margin: 2px 0;
60
+ margin: 0;
62
61
  white-space: nowrap;
63
62
  overflow: hidden;
64
63
  text-overflow: ellipsis;
@@ -70,4 +69,11 @@
70
69
 
71
70
  .resources-table {
72
71
  border-right: 1px solid #ccc;
72
+
73
+ }.resources-table .usage i {
74
+ padding: 4px;
75
+ }
76
+
77
+ .resources-table .row {
78
+ max-width: none;
73
79
  }
@@ -1,6 +1,5 @@
1
- #encoding: utf-8
2
1
  #--
3
- # Copyright (c) 2014+ Damjan Rems
2
+ # Copyright (c) 2018+ Damjan Rems
4
3
  #
5
4
  # Permission is hereby granted, free of charge, to any person obtaining
6
5
  # a copy of this software and associated documentation files (the
@@ -25,13 +24,20 @@
25
24
  module DrgcmsControls::ResourceUsageControl
26
25
 
27
26
  ######################################################################
28
- # Called when new reservation is created.
27
+ # Check if new document can be added
29
28
  ######################################################################
30
- def dc_new_record()
29
+ def dc_before_new()
31
30
  unless ( dc_user_has_role('resources-reservation') or dc_user_has_role('admin') )
31
+ params[:return_to] = 'parent.reload'
32
32
  flash[:error] = 'No permission for adding reservations!'
33
33
  return false
34
34
  end
35
+ end
36
+
37
+ ######################################################################
38
+ # Called when new reservation is created.
39
+ ######################################################################
40
+ def dc_new_record()
35
41
  @record.resource_id = params[:resource_id]
36
42
  @record.dc_user_id = session[:user_id]
37
43
  @record.time_from = params[:current_date]
@@ -1,7 +1,29 @@
1
- module ResourcesHelper
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
+ #++
2
23
 
24
+ module ResourcesHelper
3
25
  #####################################################################
4
- #
26
+ # Render single usage.
5
27
  #####################################################################
6
28
  def render_usages(resource_usages, date)
7
29
  html = ''
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2014+ Damjan Rems
2
+ # Copyright (c) 2018+ Damjan Rems
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining
5
5
  # a copy of this software and associated documentation files (the
@@ -22,13 +22,13 @@
22
22
  #++
23
23
 
24
24
  ########################################################################
25
- #
25
+ # Resources usage renderer.
26
26
  ########################################################################
27
27
  class ResourcesRenderer < DcRenderer
28
28
  include DcApplicationHelper
29
29
 
30
30
  ########################################################################
31
- #
31
+ # Render resources usage.
32
32
  ########################################################################
33
33
  def resources_usage
34
34
  time = Date.parse(@parent.params[:selected_date]) rescue DateTime.now
@@ -47,12 +47,12 @@ def resources_usage
47
47
  end
48
48
 
49
49
  ########################################################################
50
- # default renderer method will render application menu and usage table below.
50
+ # default renderer method will render application menu and usage table.
51
51
  ########################################################################
52
52
  def default
53
53
  html = @parent.render(partial: 'resources/menu', formats: [:html], locals: { parent: @parent })
54
- html << dc_flash_messages
55
- html << resources_usage#.html_safe
54
+ html << dc_flash_messages <<
55
+ resources_usage
56
56
  end
57
57
 
58
58
  end
@@ -1,4 +1,3 @@
1
- #encoding: utf-8
2
1
  #--
3
2
  # Copyright (c) 2018+ Damjan Rems
4
3
  #
@@ -53,7 +52,7 @@ class ResourceUsage
53
52
  belongs_to :resource
54
53
  belongs_to :dc_user
55
54
 
56
- index resource_id: 1
55
+ index resource_id: 1, time_from: 1
57
56
 
58
57
  validates :time_from, presence: true
59
58
  validates :time_to, presence: true
@@ -68,11 +67,11 @@ def free_time_validations
68
67
  errors.add(:time_from, "should be less then end time!") if time_from >= time_to
69
68
  errors.add(:time_from, "is less then current time!") if time_from <= Time.now
70
69
  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!")
70
+ {"$and" => [ {:time_from.lt => time_from}, {:time_to.gt => time_from} ] },
71
+ {"$and" => [ {:time_from.lt => time_to}, {:time_to.gt => time_to} ] },
72
+ {"$and" => [ {:time_from.gte => time_from}, {:time_to.lte => time_to} ] }
73
+ ] }).exists?
74
+ errors.add(:time_from, "Resource already taken!")
76
75
  end
77
76
  end
78
77
 
@@ -2,7 +2,6 @@
2
2
  <div class='resources-table' width='99%'>
3
3
  <div class="row date">
4
4
  <div class="th name"></div>
5
- <%# date = date_from; while date < date_to %>
6
5
  <% date_from.step(date_to, 1) do |date| %>
7
6
  <div class="th">
8
7
  <%= I18n.t('date.day_names')[date.wday] %><br/><%= date.strftime('%d.%m.') %>
@@ -1,3 +1,3 @@
1
1
  module DrgResourcesPlugin
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drg_resources_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damjan Rems
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-03 00:00:00.000000000 Z
11
+ date: 2018-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails