drg_cms 0.5.7 → 0.5.8

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.
@@ -720,7 +720,7 @@ def dc_choices4_all_collections
720
720
  menu['menu'].each do |section|
721
721
  next unless section.last['items'] # next if no items
722
722
  section.last['items'].each do |k, v| # look for caption and
723
- key = v['params']['table']
723
+ key = v['table']
724
724
  choices[key] ||= "#{key} - #{t(v['caption'], v['caption'])}"
725
725
  end
726
726
  end
@@ -106,8 +106,9 @@ def do_one_item(poll, yaml)
106
106
  end
107
107
  @end_od_data = true
108
108
  end
109
- # submit and link tag
110
- html << "<span class='dc-link-submit dc-animate'>#{field_html}#{yaml['separator']}</span>"
109
+ # submit and link tag
110
+ clas = yaml['type'].match(/submit_tag/) ? '' : 'dc-link-submit'
111
+ html << "<span class='#{clas} dc-animate'>#{field_html}#{yaml['separator']}</span>"
111
112
  # other elements
112
113
  else
113
114
  html << if poll.display == 'lr'
@@ -285,7 +285,7 @@ def default
285
285
  html << "<div class=\"sub-#{div_name}\">
286
286
  <ul class=\"ul-sub-#{div_name}\">"
287
287
  y = YAML.load(@selected.submenu) rescue []
288
- if y.class == Array
288
+ if y.class == Hash
289
289
  y.each do |k,v|
290
290
  html << "<li class=\"li-sub-#{div_name}\">#{@parent.link_to(v['title'], v['link'])}</li>"
291
291
  end
@@ -4,16 +4,14 @@
4
4
  <%= dc_table_title_for_result @records %>
5
5
 
6
6
  <% unless @records.nil? %>
7
- <table class="dc-result">
7
+ <table class="dc-result <%= @form['result_set']['table_class'] %>"
8
+ style="<%= @form['result_set']['table_style'] %> ">
8
9
  <tr><%= dc_header_for_result %></tr>
9
10
 
10
- <% for r in @records %>
11
- <tr class="dc-<%= cycle("odd","even")%>"
12
- data="<%= url_for(action: 'show', controller: 'cmsedit', id: r,
13
- readonly: (params[:readonly] ? 2 : 1), table: params[:table],
14
- formname: params[:formname], ids: params[:ids]) if @form['form']%>" >
15
- <%= dc_actions_for_result r %>
16
- <%= dc_columns_for_result r %>
11
+ <% for document in @records %>
12
+ <%= dc_row_for_result(document) %>
13
+ <%= dc_actions_for_result(document) %>
14
+ <%= dc_columns_for_result(document) %>
17
15
  </tr>
18
16
  <% end %>
19
17
 
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Models dump</title>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
+ <%= stylesheet_link_tag "cms", media: 'all' %>
7
+ <%= javascript_include_tag "cms" %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,47 @@
1
+ <style>
2
+ .hidden {display: none;}
3
+ .model { font-size: 1.2em; width: 952px;}
4
+ .model .col1 {padding: 3px; width: 150px; background-color: #ddd; float: left;}
5
+ .model .col2 {padding: 3px; width: 790px; background-color: #eee; float: left;}
6
+ .fields {
7
+ font-size: 1.1em; width: 952px; color: #669;
8
+ background-color: #f8f8f8; border: 1px solid #ddd;margin: 2px;
9
+ }
10
+ /*.fields {background-color: #f8f8f8;}*/
11
+ .fields .col1 {background-color: #ddd; float: left; font-weight: bold; width: 150px;padding:2px;}
12
+ .fields .col2 {padding: 4px; width: 150px; float: left;}
13
+ .fields .col3 {width: 150px; float: left;}
14
+ .fields .col4 {width: 600px; float: left;}
15
+ </style>
16
+
17
+ <% for description in descriptions; collection = description.first; fields = description.last %>
18
+ <div class="model">
19
+ <div class="col1" data-model="<%= collection['id'] %>" > <%= collection['id'] %></div>
20
+ <div class="col2" data-model="<%= collection['id'] %>" > <%= collection['description'] %></div>
21
+ <div style="clear:both;"></div>
22
+ </div>
23
+
24
+ <div id="<%= collection['id'] %>" class="fields hidden">
25
+ <div class="col1">Field name</div>
26
+ <div class="col1">Field type</div>
27
+ <div class="col1">Description</div>
28
+ <div style="clear:both;"></div>
29
+ <div style="clear:both;"></div>
30
+ <% for field in fields %>
31
+ <div class="col2"><%= field['field'] %></div>
32
+ <div class="col3"><%= field['type'] %></div>
33
+ <div class="col4"><%= field['description'] %></div>
34
+ <div style="clear:both;"></div>
35
+ <% end %>
36
+ </div>
37
+
38
+ <% end %>
39
+
40
+ <%= javascript_tag do %>
41
+ $(document).ready( function() {
42
+ $('.model').on('click',function(e) {
43
+ div_id = e.target.getAttribute("data-model");
44
+ $('#'+div_id).toggleClass('hidden');
45
+ });
46
+ });
47
+ <% end %>
@@ -82,6 +82,8 @@ en:
82
82
  new_record: New record
83
83
 
84
84
  choices4_filter_operators: 'Equal:eq,Like:like'
85
+
86
+ browse_collections: Browse all collections
85
87
 
86
88
  dc_journal:
87
89
  zero_selected: No data selected!
@@ -82,6 +82,8 @@ sl:
82
82
  new_record: Nov zapis
83
83
 
84
84
  choices4_filter_operators: 'Je enak:eq,Vsebuje:like'
85
+
86
+ browse_collections: Brskanje po zbirkah
85
87
 
86
88
  dc_journal:
87
89
  zero_selected: Ni izbranih podatkov!
@@ -478,6 +478,12 @@ en:
478
478
  key: Id key
479
479
  value: Value
480
480
 
481
+ dc_key_value_store:
482
+ tabletitle: Table used for storing all kind of values
483
+
484
+ key: Id key
485
+ value: Value
486
+
481
487
  # help for forms #####################################################
482
488
 
483
489
  help:
@@ -821,3 +827,6 @@ en:
821
827
  key: Key which defines ident
822
828
  value: Ident value
823
829
 
830
+ dc_key_value_store:
831
+ key: Identification key
832
+ value: Stored value
@@ -482,6 +482,13 @@ sl:
482
482
 
483
483
  key: Ključ
484
484
  value: Vrednost
485
+
486
+ dc_key_value_store:
487
+ tabletitle: Shramba za razna številčenja
488
+
489
+ key: Ključ
490
+ value: Vrednost
491
+
485
492
 
486
493
  # help pomoč na obrazcih ####################################################
487
494
 
@@ -833,3 +840,7 @@ sl:
833
840
  dc_ident:
834
841
  key: Ključ identifikacije (npr. DDV)
835
842
  value: Vrednost (SI12345678)
843
+
844
+ dc_key_value_store:
845
+ key: Ključ do shranjene vrednosti
846
+ value: Shranjena vrednost
@@ -1,4 +1,4 @@
1
1
  module DrgCms #:nodoc:
2
2
  # drg_cms gem version
3
- VERSION = "0.5.7"
3
+ VERSION = "0.5.8"
4
4
  end
@@ -0,0 +1,128 @@
1
+
2
+ @logger = Logger.new(STDOUT)
3
+
4
+ #########################################################################
5
+ # Determine model class from filename.
6
+ #########################################################################
7
+ def determine_model_name(path)
8
+ path =~ /(.*)\/(.*).rb/
9
+ begin
10
+ $2.camelize.constantize
11
+ $2
12
+ rescue Exception # it happends
13
+ nil
14
+ end
15
+ end
16
+
17
+ #########################################################################
18
+ # Return array of all models found in application.
19
+ #########################################################################
20
+ def all_collections()
21
+ collections = []
22
+ DrgCms.paths(:forms).each do |path|
23
+ models_dir = File.expand_path("../models", path)
24
+ Dir["#{models_dir}/*.rb"].each do |model_file|
25
+ collection_name = determine_model_name(model_file)
26
+ collections << collection_name if collection_name
27
+ end
28
+ end
29
+ collections.sort
30
+ end
31
+
32
+ #########################################################################
33
+ # Return array of all models found in application.
34
+ #########################################################################
35
+ def local_collections()
36
+ collections = []
37
+ models_dir = File.expand_path("app/models")
38
+ Dir["#{models_dir}/*.rb"].each do |model_file|
39
+ collection_name = determine_model_name(model_file)
40
+ collections << collection_name if collection_name
41
+ end
42
+ collections.sort
43
+ end
44
+
45
+ ######################################################################
46
+ # Create html list of all collections and fields
47
+ ######################################################################
48
+ def collections(what)
49
+ list = []
50
+ collections = what == 'all' ? all_collections() : local_collections()
51
+ collections.each do |collection|
52
+ model = collection.classify.constantize rescue nil
53
+ next if model.nil?
54
+ # next unless model.respond_to?(:mongo_client)
55
+ record = {'id' => collection, 'description' => I18n.t("helpers.label.#{collection}.tabletitle") }
56
+ list << [record, fields(collection)]
57
+ end
58
+ list
59
+ end
60
+
61
+ ######################################################################
62
+ # List field definition for single model
63
+ ######################################################################
64
+ def fields(collection)
65
+ records = []
66
+ model = collection.classify.constantize
67
+ document = model.new
68
+ # p document.methods
69
+ document.attribute_names.each do |attribute_name|
70
+ options = model.fields[attribute_name].options
71
+ description = I18n.t("helpers.help.#{collection}.#{attribute_name}")
72
+ description = I18n.t("helpers.label.#{collection}.#{attribute_name}") if description.match('missing:')
73
+ description = attribute_name if description.match('missing:')
74
+
75
+ records.push( {'collection' => collection,
76
+ 'field' => attribute_name,
77
+ 'type' => options[:type],
78
+ 'description' => description,
79
+ '_default' => options[:default]
80
+ } )
81
+ end
82
+ # embedded documents
83
+ document.embedded_relations.each do |a_embedded|
84
+ embedded = a_embedded.last
85
+ description = I18n.t("helpers.help.#{collection}.#{embedded.key}")
86
+ description = I18n.t("helpers.label.#{collection}.#{embedded.key}") if description.match('missing:')
87
+ description = embedded.key if description.match('missing:')
88
+
89
+ records.push( {'collection' => collection,
90
+ 'field' => embedded.key,
91
+ 'type' => 'Embedded:' + embedded.class_name,
92
+ 'description' => description
93
+ } )
94
+ end
95
+ #p records
96
+ records
97
+ end
98
+
99
+ #########################################################################
100
+ #
101
+ #########################################################################
102
+ def create_output(descriptions)
103
+ # render view which will create actual mail report
104
+ body = DcApplicationController.new.render_to_string(
105
+ :template => 'models/dump_models',
106
+ :locals => { descriptions: descriptions },
107
+ :layout => 'models'
108
+ )
109
+ File.open(Rails.root.join('public','models_dump.html'),'w') {|f| f.write(body)}
110
+ end
111
+
112
+ #########################################################################
113
+ #
114
+ #########################################################################
115
+ namespace :drg_cms do
116
+ desc "Dump all models descriptions into public/models.html"
117
+ task :dump_all_models => :environment do
118
+ descriptions = collections('all')
119
+ create_output(descriptions)
120
+ end
121
+
122
+ desc "Dump models descriptions from current project public/models.html"
123
+ task :dump_models => :environment do
124
+ descriptions = collections('local')
125
+ create_output(descriptions)
126
+ end
127
+
128
+ end
@@ -2,7 +2,7 @@
2
2
  @logger = Logger.new(STDOUT)
3
3
 
4
4
  #########################################################################
5
- # Determine module class from filename.
5
+ # Determine model class from filename.
6
6
  #########################################################################
7
7
  def determine_model(path)
8
8
  path =~ /(.*)\/(.*).rb/
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.5.7
4
+ version: 0.5.8
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-11-01 00:00:00.000000000 Z
11
+ date: 2015-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -170,7 +170,8 @@ files:
170
170
  - app/controllers/dc_application_controller.rb
171
171
  - app/controllers/dc_common_controller.rb
172
172
  - app/controllers/dc_main_controller.rb
173
- - app/controllers/drgcms_controls/dc_page_controls.rb
173
+ - app/controllers/drgcms_controls/browse_models_control.rb
174
+ - app/controllers/drgcms_controls/dc_page_control.rb
174
175
  - app/forms/all_options.yml
175
176
  - app/forms/cms_forms.yml
176
177
  - app/forms/cms_menu.yml
@@ -178,6 +179,8 @@ files:
178
179
  - app/forms/dc_big_table.yml
179
180
  - app/forms/dc_big_table_locale.yml
180
181
  - app/forms/dc_big_table_value.yml
182
+ - app/forms/dc_browse_fields.yml
183
+ - app/forms/dc_browse_models.yml
181
184
  - app/forms/dc_category.yml
182
185
  - app/forms/dc_design.yml
183
186
  - app/forms/dc_folder_permission.yml
@@ -261,11 +264,11 @@ files:
261
264
  - app/views/cmsedit/show.html.erb
262
265
  - app/views/dc_common/_iframe_edit.html.erb
263
266
  - app/views/dc_common/paste_clipboard.html.erb
264
- - app/views/dc_mail/subscribe.html.erb
265
- - app/views/dc_mail/unsubscribe.html.erb
266
267
  - app/views/layouts/__cmsedit.html.erb
267
268
  - app/views/layouts/cms.html.erb
268
269
  - app/views/layouts/content.html.erb
270
+ - app/views/layouts/models.html.erb
271
+ - app/views/models/dump_models.html.erb
269
272
  - config/initializers/kaminari_patch.rb
270
273
  - config/locales/datetimepicker.yml
271
274
  - config/locales/drgcms_en.yml
@@ -283,6 +286,7 @@ files:
283
286
  - lib/drg_cms/version.rb
284
287
  - lib/generators/new_drg_form/USAGE
285
288
  - lib/generators/new_drg_form/new_drg_form_generator.rb
289
+ - lib/tasks/browse_models.rake
286
290
  - lib/tasks/database.rake
287
291
  - lib/tasks/dc_at_the_beginning.rake
288
292
  - lib/tasks/dc_cleanup.rake
@@ -1,7 +0,0 @@
1
-
2
- <h2>Please confirm </h2>
3
- Please write down username:<%= params[:username] %>
4
- <br>password:<%= params[:password1] %>
5
- <br>
6
- <%= link_to('Start editing', controller: 'cmsedit', action: 'show') %>
7
-
@@ -1,19 +0,0 @@
1
-
2
- <h2>At the beginning GOD created superadmin</h2>
3
- <%= "<div style='color: red;'>#{flash[:error]}</div>".html_safe if flash[:error] %>
4
- <%= form_tag action: 'create', method: :put do %>
5
- <table>
6
- <tr>
7
- <td>Superadmin username:</td>
8
- <td><%= text_field(nil, 'username') %>
9
- </tr><tr>
10
- <td>Superadmin password:</td>
11
- <td><%= password_field(nil, 'password1') %>
12
- </tr><tr>
13
- <td>Repeat password:</td>
14
- <td><%= password_field(nil, 'password2') %>
15
- </tr><tr>
16
- <td><%= submit_tag %></td>
17
- </tr>
18
- </table>
19
- <% end %>