drg_cms 0.4.53 → 0.4.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2170ac5278d4127c49a981b33ffc4c7971ab2044
4
- data.tar.gz: 0d227664c634c0169283c71a1cd3dde2b49a8015
3
+ metadata.gz: c4b763f10c4908f259ef1caac04ba0a9d3cb7259
4
+ data.tar.gz: 1bdca5ace9741bb16c17c817cf81ca18953105ba
5
5
  SHA512:
6
- metadata.gz: dad0892b0d68cbaeed030987a03657e4b2fee598fb42f06bf961ed02a1e5b393201167c3fd391eed286270a22b791fc9a7e7aa3ec6a4ec9f1c8da958a573e990
7
- data.tar.gz: c6a933b22b907d199464fe1099ec205a12800a2841c80d8c92a1f76cee167ad8f2a69db4f3382b8da843f0dd69319632799398e874038143dd8fd095cbc46495
6
+ metadata.gz: 1d9a8383bb7328b1c0fc21c9d7939919ba9d716ecdfede5ebadb68bb65f1fa77ccd94060daf0159cc8e57438bd42a6934035486dec24a45305f27aee12afbe00
7
+ data.tar.gz: 95ef2a4c9a674932ac80a8dc2dc79b2adeed17d4209c60587fbb95122e9d86b8889d8a9bdb9e0ff3553ce2c96d326b7aa784aaec1b8c83d42b2d7cf7e9427dac
@@ -40,7 +40,7 @@ dumpAttributes = function(obj) {
40
40
  };
41
41
 
42
42
  /*******************************************************************
43
- * Used for removing background from iframe element. It is of course not working.
43
+ * Trying to remove background from iframe element. It is not yet working.
44
44
  *******************************************************************/
45
45
  remove_background_from_iframe = function(obj) {
46
46
  var head = obj.head;
@@ -60,7 +60,41 @@ $(function() {
60
60
  */
61
61
 
62
62
  /*******************************************************************
63
- * Process json result from ajax call and update parts of document
63
+ * Process json result from ajax call and update parts of document.
64
+ * I invented my own protocol which is arguably good or wrong.
65
+ *
66
+ * Protocol consists of operation and value which are returned as json by
67
+ * called controller. Controller will return an ajax call usually like this:
68
+ * render json: {operation: value}.to_json
69
+ *
70
+ * Operation is further divided into source and determinator which are divided by underline char.
71
+ * render json: {#div_status: 'OK!'}.to_json
72
+ * will replace html in div="status" with value 'OK!'. Source is '#div' determinator is 'status'.
73
+ *
74
+ * Possible operators are:
75
+ * record_name: will replace value of record[name] field on a form with supplied value
76
+ *
77
+ * msg_error: will display error message.
78
+ * msg_warn: will display warning message.
79
+ * msg_info: will display informational message.
80
+ *
81
+ * #div_divname : will replace divname with value
82
+ * #div+_divname : will append value to divname
83
+ * #+div_divname : will prepend value to divname
84
+ * .div_classname : will replace all accurencess of classname with value
85
+ * .+div_classname : will prepend value to all accurencess of classname
86
+ * .div+_classname : will append value to all accurencess of classname
87
+ *
88
+ * url_: Will force loading of url supplied in value into same window
89
+ * window_: Will force loading of url supplied in value into new window
90
+ * reload_: Will reload current window
91
+ *
92
+ * Operations can be chained and are executed sequentialy.
93
+ * render json: {'window_' => "/dokument.pdf", 'reload_' => 1}.to_json
94
+ * will open /dokument.pdf in new window and reload current window.
95
+ *
96
+ * render json: {'record_name' => "Damjan", 'record_surname' => 'Rems'}.to_json
97
+ * will replace values of two fields on the form.
64
98
  *******************************************************************/
65
99
  process_json_result = function(json) {
66
100
  var c = '';
@@ -111,7 +145,7 @@ process_json_result = function(json) {
111
145
  w.focus();
112
146
  break;
113
147
  case 'reload':
114
- location.reload();
148
+ location.reload();
115
149
  break;
116
150
  }
117
151
  }
@@ -515,11 +515,9 @@ background-color: #eee;
515
515
  }
516
516
 
517
517
  .iframe_embedded {
518
- border:1px solid #eee;
519
- border-right: 0px;
518
+ border: 1px solid #6cf;
520
519
  border-radius: 1px;
521
- box-shadow: 1px 1px 2px #6cf;
522
- background-color: white;
520
+ box-shadow: 1px 1px 1px #6cf;
523
521
  }
524
522
 
525
523
  #iframe_edit, #iframe_cms {
@@ -209,7 +209,7 @@ def show
209
209
  end
210
210
 
211
211
  ########################################################################
212
- # Show is used to display menu
212
+ # Login action. Used to login direct to CMS.
213
213
  ########################################################################
214
214
  def login #:nodoc:
215
215
  # session[:edit_mode] = 0 if params[:id].in? %w(login logout) # show login menu
@@ -30,15 +30,15 @@ layout false
30
30
 
31
31
  ########################################################################
32
32
  # This action is called on ajax autocomplete call. It checks if user has rights to
33
- # wiev data.
33
+ # view data.
34
34
  #
35
- # Url parameters:
35
+ # URL parameters:
36
36
  # [table] Table (collection) model name in lower case indicating table which will be searched.
37
- # [id] Name of id key field that will be returend. Default is '_id'
37
+ # [id] Name of id key field that will be returned. Default is '_id'
38
38
  # [input] Search data entered in input field.
39
39
  # [search] when passed without dot it defines field name on which search
40
40
  # will be performed. When passed with dot class_method.method_name is assumed. Method name will
41
- # be parsed and any class with class method name can be avalueted. Class method must accept
41
+ # be parsed and any class with class method name can be evaluated. Class method must accept
42
42
  # input parameter and return array [ [_id, value],.. ] which will be used in autocomplete field.
43
43
  #
44
44
  # Return:
@@ -55,7 +55,7 @@ def autocomplete
55
55
  a = if params['search'].match(/\./)
56
56
  name, method = params['search'].split('.')
57
57
  table.send(method, params['input']).inject([]) do |r,v|
58
- r << { label: v[1], value: v[1], id: v[0].to_s }
58
+ r << { label: v[0], value: v[0], id: v[1].to_s }
59
59
  end
60
60
  # simply search which will search and return field_name defined in params['search']
61
61
  else
@@ -63,6 +63,7 @@ def autocomplete
63
63
  r << { label: v[params['search']], value: v[params['search']], id: v.id.to_s }
64
64
  end
65
65
  end
66
+ p a
66
67
  render inline: a.to_json, formats: 'js'
67
68
  end
68
69
 
@@ -87,7 +88,7 @@ end
87
88
  ##########################################################################
88
89
  def toggle_edit_mode
89
90
  session[:edit_mode] ||= 0
90
- # called directly without authorization
91
+ # called without logged in
91
92
  if session[:edit_mode] < 1
92
93
  dc_render_404
93
94
  else
@@ -100,7 +101,7 @@ end
100
101
  # Default user login action.
101
102
  ####################################################################
102
103
  def process_login
103
- # Something is really wrong
104
+ # Somebody is probably playing
104
105
  return dc_render_404 unless ( params[:record] and params[:record][:username] and params[:record][:password] )
105
106
 
106
107
  if params[:record][:password].to_s.size > 0 #password must not be empty
@@ -139,8 +140,6 @@ def login
139
140
  end
140
141
  end
141
142
  # Display login
142
- # redirect_to controller: 'poll', poll_id: 'login', return_to: params[:return_to]
143
- # redirect_to( {host: 'poll', poll_id: 'login', return_to: params[:return_to]} )
144
143
  route = params[:route] || 'poll'
145
144
  redirect_to "/#{route}?poll_id=login&return_to=#{params[:return_to]}"
146
145
  end
@@ -149,6 +148,8 @@ end
149
148
  # Action is called when restore document from journal is requested.
150
149
  ####################################################################
151
150
  def restore_from_journal
151
+ # Only administrators can perform this operation
152
+ return render(text: t('drgcms.not_authorized') ) unless dc_user_has_role('admin')
152
153
  # selected fields to hash
153
154
  restore = params[:select].inject({}) {|r,v| r[v.first] = 0 if v.last == '1'; r}
154
155
  result = if restore.size == 0
@@ -0,0 +1,28 @@
1
+ ## YAML Template for drgcms_menu1s
2
+ ---
3
+ title: drgCMS First Top Menu
4
+ table: drgcms1menu
5
+ new_part:
6
+ form:
7
+ actions:
8
+ 1: cancle
9
+ 2:
10
+ type: submit
11
+ text: Create
12
+
13
+ fields:
14
+ 1:
15
+ name: part_type
16
+ type: select
17
+ choices: part,drgcms1menu
18
+ eval: Person.all.collect {|p| [ p.name, p.id ] }
19
+
20
+ 2:
21
+ name: part_embedded_in
22
+ type: select
23
+ choices: Design:design,PodjetnikPage:podjetnik_page
24
+
25
+ 3:
26
+ name: location_id
27
+ type: select
28
+ choices: site-top,ads-top,site-right,site-bottom,&get_all_locations
@@ -1,5 +1,4 @@
1
1
  ---
2
- title: Additional identification
3
2
  table: dc_ident
4
3
 
5
4
  index:
@@ -31,7 +30,7 @@ form:
31
30
  size: 30
32
31
  20:
33
32
  name: value
34
- type: file_select
33
+ type: text_field
35
34
  html:
36
- size: 50
35
+ size: 30
37
36
 
@@ -1,6 +1,5 @@
1
1
  ## YAML Template for Link
2
2
  ---
3
- title: Shortcut links
4
3
  table: dc_link
5
4
 
6
5
  index:
@@ -1,7 +1,5 @@
1
1
  ## YAML Template for dc_simple_menu_items
2
2
  ---
3
- title: Menu item
4
- #parent_name: caption
5
3
  table: dc_menu_item
6
4
 
7
5
  index:
@@ -1,6 +1,5 @@
1
1
  ## YAML Template for page
2
2
  ---
3
- title: Page
4
3
  table: dc_page
5
4
 
6
5
  index:
@@ -1,6 +1,5 @@
1
1
  ## YAML Template for page
2
2
  ---
3
- title: Part
4
3
  table: dc_part
5
4
 
6
5
  index:
@@ -35,6 +34,11 @@ form:
35
34
  type: text_field
36
35
  html:
37
36
  size: 50
37
+ 15:
38
+ name: link
39
+ type: text_field
40
+ html:
41
+ size: 50
38
42
  20:
39
43
  name: description
40
44
  type: text_field
@@ -1,6 +1,5 @@
1
1
  ## YAML Template for piece
2
2
  ---
3
- title: Piece
4
3
  table: dc_piece
5
4
 
6
5
  index:
@@ -1,6 +1,5 @@
1
1
  ## YAML Template for Policy
2
2
  ---
3
- title: Policy
4
3
  table: dc_policy
5
4
 
6
5
  index:
@@ -1,6 +1,5 @@
1
1
  ## YAML Template for Polls
2
2
  ---
3
- title: Polls
4
3
  table: dc_poll
5
4
 
6
5
  index:
@@ -1,7 +1,5 @@
1
1
  ## YAML Template for dc_simple_menu_items
2
2
  ---
3
- title: Simple menu items
4
- #parent_name: description
5
3
  table: dc_simple_menu_item
6
4
 
7
5
  index:
@@ -1,6 +1,5 @@
1
1
  ## YAML Template for drgcms_menu1s
2
2
  ---
3
- title: User roles
4
3
  table: dc_user_role
5
4
 
6
5
  index:
@@ -312,7 +312,7 @@ def dc_format_value(value, format=nil)
312
312
  format ||= t('date.formats.default')
313
313
  value.strftime(format)
314
314
  else
315
- value
315
+ value.to_s
316
316
  end
317
317
  end
318
318
 
@@ -75,7 +75,7 @@ def self.choices4_policies
75
75
  end
76
76
 
77
77
  ########################################################################
78
- # Returns value of site setting. If no value send as parameter it returns
78
+ # Returns value of site setting. If no value is send as parameter it returns
79
79
  # all settings hash object.
80
80
  ########################################################################
81
81
  def params(what=nil)
@@ -280,7 +280,19 @@ end
280
280
  # Implementation of multitext_autocomplete DRG CMS form field.
281
281
  #
282
282
  # multitext_autocomplete field is complex data entry field which uses autocomplete
283
- # function when selecting multiple values for Array MongoDB field.
283
+ # function when selecting multiple values for MongoDB Array field. Array typically holds
284
+ # id's of selected documents and control typically displays value of the field name
285
+ # defined by search options.
286
+ #
287
+ # Form options:
288
+ # [name] field name
289
+ # [table] Collection (table) name
290
+ # [search] Search may consist of three parameters from which last is not required. Parameters
291
+ # can be separated either by dot (.) or comma(,) table_name.display_field_name.(table_name_search_method)
292
+ # table_name is name of collection, display_field_name will be used for displaying value of selected
293
+ # document ids on screen. Optional search method can be defined when searched documents are
294
+ # only subset of all documents and additional query is required.
295
+ # [html] Various html options which can be applied to input object.
284
296
  ###########################################################################
285
297
  class MultitextAutocomplete < DrgcmsField
286
298
 
@@ -302,10 +314,11 @@ end
302
314
  ###########################################################################
303
315
  def render
304
316
  # search field name
305
- if @yaml['search'].match(/\./)
306
- table, search = @yaml['search'].split('.')
307
- else
308
- search = @yaml['search']
317
+ if @yaml['search'].to_s.match(/\./)
318
+ table, field_name, method = @yaml['search'].split(/\.|\,/)
319
+ search = method.nil? ? field_name : "#{field_name}.#{method}"
320
+ else # search and table name are separated
321
+ search = field_name = @yaml['search']
309
322
  end
310
323
  # determine table name
311
324
  if @yaml['table']
@@ -319,9 +332,18 @@ def render
319
332
  nil
320
333
  end
321
334
  end
322
- return 'Table or search field not defined!' unless (table and search)
335
+ unless (table and search)
336
+ @html << 'Table or search field not defined!'
337
+ return self
338
+ end
323
339
  #
324
340
  return ro_standard(table, search) if @readonly
341
+ # TODO check if table exists
342
+ collection = table.classify.constantize
343
+ unless @record.respond_to?(@yaml['name'])
344
+ @html << "Invalid field name: #{@yaml['name']}"
345
+ return self
346
+ end
325
347
  # put field to enter search data on form
326
348
  @yaml['html'] ||= {}
327
349
  @yaml['html']['value'] = '' # must be. Otherwise it will look into record and return error
@@ -330,8 +352,6 @@ def render
330
352
  @html << @parent.link_to(@parent.image_tag('drg_cms/add.png', class: 'dc-link-img'), '#',onclick: 'return false;') # dummy add. But it is usefull.
331
353
  @html << ' ' << @parent.text_field('record', _name, @yaml['html']) # text field for autocomplete
332
354
  @html << "<div id =\"record#{@yaml['name']}\">" # div to list active records
333
- # TODO check if table exists
334
- t = table.classify.constantize
335
355
  # find value for each field inside categories
336
356
  unless @record[@yaml['name']].nil?
337
357
  @record[@yaml['name']].each do |element|
@@ -339,16 +359,16 @@ def render
339
359
  # more complicated options
340
360
  # TODO retrieve choices from big_table
341
361
  rec = if table == 'dc_big_table'
342
- t.find(@yaml['name'], @parent.session)
362
+ collection.find(@yaml['name'], @parent.session)
343
363
  else
344
- t.find(element)
364
+ collection.find(element)
345
365
  end
346
366
  # Related data is missing. It happends.
347
367
  @html << if rec
348
368
  link = @parent.link_to(@parent.image_tag('drg_cms/x.png', class: 'dc-link-img'), '#',
349
369
  onclick: "$('##{rec.id}').hide(); var v = $('#record_#{@yaml['name']}_#{rec.id}'); v.val(\"-\" + v.val());return false;")
350
370
  field = @parent.hidden_field('record', "#{@yaml['name']}_#{rec.id}", value: element)
351
- "<div id=\"#{rec.id}\">#{link} #{rec[search]}<br>#{field}</div>"
371
+ "<div id=\"#{rec.id}\">#{link} #{rec[field_name]}<br>#{field}</div>"
352
372
  else
353
373
  '** error **'
354
374
  end
@@ -411,6 +431,23 @@ end
411
431
 
412
432
  ###########################################################################
413
433
  # Implementation of select DRG CMS form field.
434
+ #
435
+ # Form options:
436
+ # [name] field name
437
+ # [choices] Values for choices separated by comma. Values can also be specified like description:value.
438
+ # In this case description will be shown to user, but value will be saved to document.
439
+ # choices: 'OK:0,Ready:1,Error:2'
440
+ # choices: Ruby,Pyton,PHP
441
+ # [eval] Choices will be provided by evaluating expression
442
+ # eval: dc_choices4('model_name','description_field_name','_id') # call dc_choices4 method
443
+ # eval: DcPolicyRole.choices4_roles # call class method choices4_roles in DcPolicyRole class definition.
444
+ # If choices or eval is not defined choices will be provided from translation helpers. If you have
445
+ # field status on a form choices may be provided by en.helpers.model_name.choices4_status entry of
446
+ # english translation. English is of course default translation. If you provide translations in
447
+ # your own language then select choices will be localized.
448
+ # sl.helpers.model_name.choices4_status: 'V redu:0,Pripravljen:1,Napaka:2'
449
+ #
450
+ # [html] html options which can be applied to select field.
414
451
  ###########################################################################
415
452
  class Select < DrgcmsField
416
453
 
@@ -687,7 +724,7 @@ end
687
724
  # DatePicker get_data method.
688
725
  ###########################################################################
689
726
  def self.get_data(params, name)
690
- t = params['record'][name].to_datetime
727
+ t = params['record'][name] ? params['record'][name].to_datetime : nil
691
728
  t ? Time.zone.local(t.year, t.month, t.day) : nil
692
729
  end
693
730
 
@@ -728,7 +765,7 @@ end
728
765
  # DateTimePicker get_data method.
729
766
  ###########################################################################
730
767
  def self.get_data(params, name)
731
- t = params['record'][name].to_datetime
768
+ t = params['record'][name] ? params['record'][name].to_datetime : nil
732
769
  t ? Time.zone.local(t.year, t.month, t.day, t.hour, t.min) : nil
733
770
  end
734
771
 
@@ -83,17 +83,6 @@ en:
83
83
  zero_selected: No data selected!
84
84
  restored: Data has been restored.
85
85
  restore: Restore
86
-
87
- dc_mail:
88
- send: Send
89
- send_to_test: Send test
90
- mail_sent: Mail sending procedure was started!
91
- test_mail_sent: Mail send to test recipient!
92
- message_status_error: Message status must be Ready to send!
93
- message_sent_to: "Message sent to %{number} address(es)."
94
- message_errors: "%{number} addresses were in error!"
95
- report: Report
96
- unsubscription: Unsubscription
97
86
 
98
87
  dc_captcha:
99
88
  simple_message: Please write in the name of month no %{number} in a year.
@@ -83,16 +83,4 @@ sl:
83
83
  zero_selected: Ni izbranih podatkov!
84
84
  restored: Podatki so restavrirani.
85
85
  restore: Restavriraj
86
-
87
- dc_mail:
88
- send: Pošlji
89
- send_to_test: Pošlji test
90
- mail_sent: Postopek za pošiljanje sporočila je zagnan!
91
- test_mail_sent: Sporočilo je bilo poslano na naslov za test!
92
- message_status_error: Stanje sporočila mora biti pripravljeno!
93
- message_sent_to: "Sporočilo je bilo poslano na %{number} naslov(ov)."
94
- message_errors: "%{number} naslov(ov) z napakami!"
95
- report: Poročilo
96
- unsubscription: Odjava
97
-
98
86
 
@@ -810,5 +810,5 @@ sl:
810
810
  diff: Razlike
811
811
 
812
812
  dc_ident:
813
- key: Ključ identifikacije
814
- value: Vrednost
813
+ key: Ključ identifikacije (npr. DDV)
814
+ value: Vrednost (SI12345678)
@@ -1,4 +1,4 @@
1
1
  module DrgCms #:nodoc:
2
2
  # drg_cms gem version
3
- VERSION = "0.4.53"
3
+ VERSION = "0.4.54"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drg_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.53
4
+ version: 0.4.54
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damjan Rems
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-22 00:00:00.000000000 Z
11
+ date: 2015-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -156,6 +156,7 @@ files:
156
156
  - app/controllers/dc_common_controller.rb
157
157
  - app/controllers/dc_main_controller.rb
158
158
  - app/controllers/drgcms_controls/dc_page_controls.rb
159
+ - app/forms/__drgcms_cms.yml
159
160
  - app/forms/all_options.yml
160
161
  - app/forms/cms_forms.yml
161
162
  - app/forms/cms_menu.yml
@@ -200,7 +201,6 @@ files:
200
201
  - app/helpers/dc_poll_renderer.rb
201
202
  - app/helpers/dc_renderer.rb
202
203
  - app/helpers/dc_simple_menu_renderer.rb
203
- - app/models/__dc_stat.rb
204
204
  - app/models/dc_ad.rb
205
205
  - app/models/dc_ad_stat.rb
206
206
  - app/models/dc_big_menu.rb
@@ -1,43 +0,0 @@
1
- #--
2
- # Copyright (c) 2012+ 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
- # Mongoid::Document model for dc_stat documents.
26
- #
27
- #
28
- ########################################################################
29
-
30
- class DcStat #:nodoc:
31
- include Mongoid::Document
32
- include Mongoid::Timestamps
33
-
34
- field :key1, type: String
35
- field :key2, type: String
36
- field :key3, type: String
37
- field :value, type: Integer, default: 0
38
- field :text1, type: String
39
- field :text2, type: String
40
- field :link, type: String
41
-
42
- index( { key1: 1, key2: 1, key3: 1 } )
43
- end