agile_rails 0.0.0.2 → 0.0.0.3

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
  SHA256:
3
- metadata.gz: 18dcbd28e6f1f0d840016fadd4a0ffc75da43233dac60f772b67d36de0a9f534
4
- data.tar.gz: 19c2c9e047772cf7e26ad2073093803f9dd090cde50090931041ba94dfcd5a54
3
+ metadata.gz: 0bd422185ce90e64f9e1df6198d36c58a7fe951c54e7ba874a99aa12d9c80bf3
4
+ data.tar.gz: 843970c74ad00cc5784620361886a4532637a746de2833a77691cbea5852f140
5
5
  SHA512:
6
- metadata.gz: 3db8f8adb6b0e7c495cc43c2fe08e6f699ac69efda6371ff24cf9afe769b890637f4f962b3352501ab2d5fcdcaba147e6400411c27865af480df3582abb26a8c
7
- data.tar.gz: 7824f2db93018f2f72f8247e76af3b3c83172be2a9a0b2ff9985199cc7ae219746af44cee0425261f263ae05dc3f4e5f8bc0ddc0e85a7795ed982c7e5a72d29e
6
+ metadata.gz: b06646b7230db54483a3164e8a1f06ab1fd74ed5713dc464067762d85008ac58a33de789980a5937cd3c7ede05392ede91c5d98c29b39d2d25b280914bf98577
7
+ data.tar.gz: 5ed95ba34ac30d4ca3d816fedf2220b569dd24036ba92a8c4c0f00d4d280dbdfb18313d1597fe61726b8625dc63c45a567bb67c9447b83f0b1c37f4b445781e1
data/README.md CHANGED
@@ -249,7 +249,7 @@ agile_rails_html_editor gem.
249
249
 
250
250
  Installation
251
251
  ------------
252
- Go and [jumpstart](https://github.com/agile-rails/startup/README.md)
252
+ Go and [jumpstart](https://github.com/agile-rails/startup)
253
253
  Intranet portal application with AgileRails in just few minutes.
254
254
 
255
255
  Compatibility
@@ -348,6 +348,10 @@ process_json_result = function(json) {
348
348
  case 'parenturl':
349
349
  parent.location.href = value;
350
350
  break;
351
+ case 'iframeurl':
352
+ let [iframe, url] = value.split(";");
353
+ document.getElementById(iframe).src = url
354
+ break;
351
355
  case 'alert':
352
356
  alert(value);
353
357
  break;
@@ -532,6 +536,7 @@ function handleIframeFocus(){
532
536
 
533
537
  var active_iframe = null;
534
538
  */
539
+ let timeoutId = null;
535
540
 
536
541
  /*******************************************************************
537
542
  * Events start here
@@ -1008,7 +1013,33 @@ $(document).ready( function() {
1008
1013
  }
1009
1014
  });
1010
1015
 
1011
- /*******************************************************************
1016
+ /*******************************************************************
1017
+ * Help text is displayed as title when mouse hovered over label.
1018
+ * This was not wery obvious so, help icon was added to label
1019
+ * and help text is also displayed if user clicks on label text.
1020
+ *******************************************************************/
1021
+ $('.ar-form-label').on('click', function(e) {
1022
+ let titleText = $(this).attr('title');
1023
+ if (!titleText || titleText == ' ' ) return;
1024
+
1025
+ $('#popup')
1026
+ .text(titleText)
1027
+ .css({
1028
+ left: e.pageX + 10 + 'px',
1029
+ top: e.pageY + 10 + 'px',
1030
+ display: 'block'
1031
+ });
1032
+ $('#popup').addClass('tooltip');
1033
+
1034
+ if (timeoutId) clearTimeout(timeoutId);
1035
+ timeoutId = setTimeout(function () {
1036
+ $('#popup').css({display: 'none'});
1037
+ $('#popup').removeClass('tooltip');
1038
+ timeoutId = null;
1039
+ }, 3000);
1040
+ });
1041
+
1042
+ /*******************************************************************
1012
1043
  * It is not possible to attach any data to submit button except the text
1013
1044
  * that is written on a button and it is therefore very hard to distinguish
1014
1045
  * which button was pressed when more than one button is present on a form.
@@ -791,6 +791,19 @@ display: inline-table;
791
791
  margin-left: 4px;
792
792
  }
793
793
 
794
+ .ar-form-label::after {
795
+ font-size: 0.9em;
796
+ content: '?';
797
+ color: #253858;
798
+ background-color: #E0EEFF;
799
+ border-radius: 10px;
800
+ padding: 0 6px;
801
+ border: 1px solid #E8EAEC;
802
+ }
803
+
804
+ .ar-form-label.no-help::after { display: none; }
805
+
806
+
794
807
  .ar-form-label label {
795
808
  padding: 0 4px;
796
809
  font-size: 1em;
@@ -1698,6 +1711,14 @@ font-size: 1.2em;
1698
1711
  cursor: pointer;
1699
1712
  }
1700
1713
 
1714
+ #popup.tooltip {
1715
+ filter: none;
1716
+ position: fixed;
1717
+ border: 1px solid #666;
1718
+ background: lemonchiffon;
1719
+ z-index: 1000;
1720
+ }
1721
+
1701
1722
  /************************** info popup *************************/
1702
1723
  #ar-document-info {
1703
1724
  position: absolute;
@@ -173,6 +173,7 @@ def new
173
173
  # not authorized
174
174
  unless agile_user_can(ArPermission::CAN_CREATE)
175
175
  flash[:error] = t('agile.not_authorized')
176
+ logger.error("******* #{t('agile.not_authorized')} #{session[:user_name]} #{AgileHelper.table_param(params)}")
176
177
  return index
177
178
  end
178
179
  create_new_empty_record()
@@ -34,6 +34,15 @@ def new_record
34
34
  ArTemp.clear(temp_key) unless params[:clear].to_s == 'no'
35
35
  end
36
36
 
37
+ ######################################################################
38
+ # Return url for report iframe with additional parameters. Use when you need
39
+ # to send additional parameters to resulting iframe.
40
+ ######################################################################
41
+ def report_url_for(params = {})
42
+ url = "if_ar_temp;/agile?field_name=ar_temp&iframe=if_ar_temp&table=ar_temp&form_name=#{@report_id}"
43
+ params.inject(url) { |r, v| "#{r}&#{v[0]}=#{v[1]}" }
44
+ end
45
+
37
46
  ######################################################################
38
47
  # Will replace @form with @form['report'] if table=ar_temp.
39
48
  # Will load agile_report_defaults if table=ar_memory and actions are not present.
@@ -38,7 +38,6 @@ def update_form
38
38
  save_filter_value(filter, 'ar_setup', :filter)
39
39
  end
40
40
  end
41
-
42
41
  return unless params[:id]
43
42
 
44
43
  record = if params[:id].to_i.to_s == params[:id]
@@ -48,11 +47,11 @@ def update_form
48
47
  end
49
48
 
50
49
  unless agile_user_has_role?('admin')
51
- @form['form'].delete('tabs')
50
+ @form['form']['tabs'] = {}
52
51
  @form['readonly'] = true unless record.editors.include?(session[:user_id])
53
52
  end
54
53
 
55
- form = YAML.load(record.form) #rescue nil
54
+ form = YAML.load(record.form)
56
55
  if form.present?
57
56
  @form['form']['tabs'] ||= {}
58
57
  @form['form']['tabs'].merge!(form)
@@ -3,8 +3,7 @@
3
3
  extend: ar_category
4
4
 
5
5
  index:
6
- actions:
7
- 10: /
6
+ actions: /
8
7
 
9
8
  data_set:
10
9
  type: method
@@ -61,7 +61,7 @@ attr_reader :json_ld
61
61
 
62
62
  ############################################################################
63
63
  # When @env is present then helper methods are called from @env object otherwise
64
- # from self.
64
+ # from self.
65
65
  ############################################################################
66
66
  def _origin #:nodoc:
67
67
  @env || self
@@ -77,17 +77,17 @@ end
77
77
 
78
78
  ############################################################################
79
79
  # This is main method used for render parts of design into final HTML document.
80
- #
80
+ #
81
81
  # Parameters:
82
- # [renderer] String or Symbol. Class name (in lowercase) that will be used to render final HTML code.
82
+ # [renderer] String or Symbol. Class name (in lowercase) that will be used to render final HTML code.
83
83
  # If class name is provided without '_renderer' suffix it will be added automatically.
84
- #
84
+ #
85
85
  # When renderer has value :part, it is a shortcut for agile_render_part method which
86
86
  # is used to draw parts of layout on design.
87
- #
87
+ #
88
88
  # [opts] Hash. Additional options that are passed to method. Options are merged with
89
89
  # options set on site, design, page and passed to renderer object.
90
- #
90
+ #
91
91
  # Example:
92
92
  # <%= agile_render(:ar_page, method: 'view', category: 'news') %>
93
93
  ############################################################################
@@ -123,7 +123,7 @@ end
123
123
  # Point is to define design once and replace some parts of design dynamically.
124
124
  # Design may be defined in site and design doc defines only parts that vary
125
125
  # from page to page.
126
- #
126
+ #
127
127
  # Example: As used in design.
128
128
  # <%= agile_render_part(@main) %>
129
129
  #
@@ -140,8 +140,8 @@ def agile_render_part(part)
140
140
  # called. That is what is defined in second part of array.
141
141
  when part.instance_of?(Array)
142
142
  if @options.dig(:settings, part.first)
143
- #TODO to be defined
144
- else
143
+ #TODO to be defined
144
+ else
145
145
  result = part.last.call
146
146
  result.instance_of?(Array) ? result.first : result
147
147
  end
@@ -176,9 +176,9 @@ def agile_page_bottom
176
176
  end
177
177
 
178
178
  ############################################################################
179
- # Creates title div for AgileRails dialogs. Title may also contain pagination section on right side if
179
+ # Creates title div for AgileRails dialogs. Title may also contain pagination section on right side if
180
180
  # data_set is provided as parameter.
181
- #
181
+ #
182
182
  # Parameters:
183
183
  # [text] String. Title caption.
184
184
  # [data_set=nil] Document collection. If data_set is passed pagination links will be created.
@@ -224,7 +224,7 @@ end
224
224
 
225
225
  ############################################################################
226
226
  # Creates title for AgileRails new dialog
227
- #
227
+ #
228
228
  # Returns:
229
229
  # String. HTML code for title.
230
230
  ############################################################################
@@ -328,7 +328,7 @@ end
328
328
 
329
329
  ####################################################################
330
330
  # Returns flash messages formatted for display on message div.
331
- #
331
+ #
332
332
  # Returns:
333
333
  # String. HTML code formatted for display.
334
334
  ####################################################################
@@ -363,10 +363,10 @@ end
363
363
  ########################################################################
364
364
  # Decamelizes string. This probably doesn't work very good with non ascii chars.
365
365
  # Therefore it is very unwise to use non ascii chars for table (table) names.
366
- #
367
- # Parameters:
366
+ #
367
+ # Parameters:
368
368
  # [Object] model_string. String or model to be converted into decamelized string.
369
- #
369
+ #
370
370
  # Returns:
371
371
  # String. Decamelized string.
372
372
  ########################################################################
@@ -375,12 +375,12 @@ def decamelize_type(model_string)
375
375
  end
376
376
 
377
377
  ####################################################################
378
- # Returns validation error messages for the document (record) formatted for
378
+ # Returns validation error messages for the document (record) formatted for
379
379
  # display on message div.
380
- #
381
- # Parameters:
380
+ #
381
+ # Parameters:
382
382
  # [doc] Document. Document record which will be checked for errors.
383
- #
383
+ #
384
384
  # Returns:
385
385
  # String. HTML code formatted for display.
386
386
  ####################################################################
@@ -389,11 +389,11 @@ def agile_error_messages_for(doc)
389
389
 
390
390
  msgs = doc.errors.inject('') do |r, error|
391
391
  label = t("helpers.label.#{decamelize_type(doc.class)}.#{error.attribute}", error.attribute)
392
- r + "<li>#{label} : #{error.message}</li>"
392
+ "#{r}<li>#{label} : #{error.message}</li>"
393
393
  end
394
394
 
395
395
  %(
396
- <div class="ar-form-error">
396
+ <div class="ar-form-error">
397
397
  <h2>#{t('agile.errors_no')} #{doc.errors.size}</h2>
398
398
  <ul>#{msgs}</ul>
399
399
  </div>).html_safe
@@ -416,11 +416,11 @@ def agile_warning_messages_for(doc)
416
416
 
417
417
  msgs = doc.warnings.inject('') do |r, error|
418
418
  label = t("helpers.label.#{decamelize_type(doc.class)}.#{error.attribute}", error.attribute)
419
- r + "<li>#{label} : #{error.message}</li>"
419
+ "#{r}<li>#{label} : #{error.message}</li>"
420
420
  end
421
421
 
422
422
  %(
423
- <div class="ar-form-warning">
423
+ <div class="ar-form-warning">
424
424
  <h2>#{t('agile.warnings_no')} #{doc.warnings.size}</h2>
425
425
  <ul>#{msgs}</ul>
426
426
  </div>).html_safe
@@ -438,39 +438,39 @@ end
438
438
 
439
439
  ####################################################################
440
440
  # Will create HTML code required to create new document.
441
- #
442
- # Parameters:
441
+ #
442
+ # Parameters:
443
443
  # [opts] Hash. Optional parameters for url_for helper. These options must provide at least table and form_name
444
- # parameters.
445
- #
444
+ # parameters.
445
+ #
446
446
  # Example:
447
447
  # if @opts[:edit_mode] > 1
448
448
  # opts = {table: 'agile_page;agile_part', form_name: 'agile_part', ids: @doc.id }
449
449
  # html += agile_link_for_create( opts.merge!({title: 'Add new part', 'agile_part.name' => 'initial name', 'agile_part.order' => 10}) )
450
450
  # end
451
- #
451
+ #
452
452
  # Returns:
453
453
  # String. HTML code which includes add image and javascript to invoke new document create action.
454
454
  ####################################################################
455
455
  def agile_link_for_create(opts)
456
- opts.stringify_keys!
456
+ opts.stringify_keys!
457
457
  title = opts.delete('title') #
458
458
  title = t(title, title) if title
459
- target = opts.delete('target') || 'iframe_cms'
459
+ target = opts.delete('target') || 'iframe_cms'
460
460
  opts['form_name'] ||= opts['table'].to_s.split(';').last
461
461
  opts['action'] = :new
462
462
  opts['controller'] ||= :agile
463
463
  url_forward_params(opts)
464
464
  js = "$('##{target}').attr('src', '#{_origin.url_for(opts)}'); return false;"
465
465
  agile_link_to(nil, _origin.mi_icon('plus-circle'), '#',
466
- { onclick: js, title: title, alt: 'Create', class: 'ar-inline-link'}).html_safe
466
+ { onclick: js, title: title, alt: 'Create', class: 'ar-inline-link'}).html_safe
467
467
  end
468
468
 
469
469
  ####################################################################
470
470
  # Will create HTML code required to edit document.
471
- #
472
- # Parameters:
473
- # [opts] Hash. Optional parameters for url_for helper. These options must provide
471
+ #
472
+ # Parameters:
473
+ # [opts] Hash. Optional parameters for url_for helper. These options must provide
474
474
  # at least table, form_name and id parameters. Optional title, target and icon parameters
475
475
  # can be set.
476
476
  #
@@ -481,7 +481,7 @@ end
481
481
  # String. HTML code which includes edit image and javascript to invoke edit document action.
482
482
  ####################################################################
483
483
  def agile_link_for_edit(opts)
484
- opts.stringify_keys!
484
+ opts.stringify_keys!
485
485
  title = opts.delete('title') #
486
486
  title = t(title)
487
487
  target = opts.delete('target') || 'iframe_cms'
@@ -490,9 +490,9 @@ def agile_link_for_edit(opts)
490
490
  opts['action'] ||= 'edit'
491
491
  opts['form_name'] ||= opts['table'].to_s.split(';').last
492
492
 
493
- js = "$('##{target}').attr('src', '#{_origin.url_for(opts)}'); return false;"
493
+ js = "$('##{target}').attr('src', '#{_origin.url_for(opts)}'); return false;"
494
494
  agile_link_to(nil, _origin.mi_icon(icon), '#',
495
- { onclick: js, title: title, class: 'ar-inline-link', alt: 'Edit'})
495
+ { onclick: js, title: title, class: 'ar-inline-link', alt: 'Edit'})
496
496
  end
497
497
 
498
498
  ####################################################################
@@ -509,7 +509,7 @@ def agile_link_menu_tag(title) #:nodoc:
509
509
  )
510
510
 
511
511
  yield html
512
- html + '</ul></dd></dl>'
512
+ "#{html}</ul></dd></dl>"
513
513
  end
514
514
 
515
515
  ####################################################################
@@ -529,15 +529,15 @@ end
529
529
  # * Edit advanced. Will create edit form for editing all document fields.
530
530
  # * New page. Will create new document and pass some initial data to it. Initial data is saved to cookie.
531
531
  # * New part. Will create new part of document.
532
- #
532
+ #
533
533
  # Parameters:
534
534
  # [opts] Hash. Optional parameters for url_for helper. These options must provide at least table and form_name
535
- # and id parameters.
536
- #
535
+ # and id parameters.
536
+ #
537
537
  # Example:
538
538
  # html += agile_page_edit_menu() if @opts[:edit_mode] > 1
539
- #
540
- # Returns:
539
+ #
540
+ # Returns:
541
541
  # String. HTML code required for manipulation of currently processed document.
542
542
  ########################################################################
543
543
  def agile_page_edit_menu(opts = @opts)
@@ -550,8 +550,8 @@ def agile_page_edit_menu(opts = @opts)
550
550
  kukis = { "#{table}.ar_design_id" => page.ar_design_id,
551
551
  # "#{table}.menu_id" => page.menu_id,
552
552
  # "#{table}.kats" => page.kats,
553
- "#{table}.page_id" => page.id,
554
- "#{table}.ar_site_id" => _origin.site.id
553
+ "#{table}.page_id" => page.id,
554
+ "#{table}.ar_site_id" => _origin.site.id
555
555
  }
556
556
  _origin.cookies[:record] = Marshal.dump(kukis)
557
557
  title = "#{t('agile.edit')}: #{page.subject}"
@@ -568,17 +568,17 @@ def agile_page_edit_menu(opts = @opts)
568
568
  html += agile_link_for_edit1( opts[:edit_params], t('agile.edit_new_page') )
569
569
 
570
570
  opts[:edit_params].merge!(ids: page.id, form_name: 'agile_part', 'icon' => 'plus',
571
- table: "#{_origin.site.page_class.underscore};agile_part" )
571
+ table: "#{_origin.site.page_class.underscore};agile_part" )
572
572
  html + agile_link_for_edit1( opts[:edit_params], t('agile.edit_new_part') )
573
573
  end.html_safe
574
574
  end
575
575
 
576
576
  ########################################################################
577
- # Return page class model defined in site document page_class field.
578
- #
579
- # Used in forms, when method must be called from page model and model is overwritten by
577
+ # Return page class model defined in site document page_class field.
578
+ #
579
+ # Used in forms, when method must be called from page model and model is overwritten by
580
580
  # user's own model.
581
- #
581
+ #
582
582
  # Example as used on form:
583
583
  # 30:
584
584
  # name: link
@@ -590,10 +590,10 @@ def agile_page_class
590
590
  end
591
591
 
592
592
  ########################################################################
593
- # Return menu class model defined in site document menu_class field.
594
- #
593
+ # Return menu class model defined in site document menu_class field.
594
+ #
595
595
  # Used in forms for providing menus class to the forms object.
596
- #
596
+ #
597
597
  # Example as used on form:
598
598
  # 30:
599
599
  # name: menu_id
@@ -607,10 +607,10 @@ end
607
607
  ####################################################################
608
608
  # Parse site name from url and return ar_site document. Site document will be cached in
609
609
  # @site variable.
610
- #
610
+ #
611
611
  # If not in production environment and site document is not found
612
612
  # method will search for 'test' document and return ar_site document found in alias_for field.
613
- #
613
+ #
614
614
  # Returns:
615
615
  # ArSite. Site document.
616
616
  ####################################################################
@@ -635,7 +635,7 @@ end
635
635
  # Return array of policies defined in a site document formated to be used
636
636
  # as choices for select field. Method is used for selecting site policy where
637
637
  # policy for displaying data is required.
638
- #
638
+ #
639
639
  # Example (as used in forms):
640
640
  # name: policy_id
641
641
  # type: select
@@ -649,8 +649,8 @@ end
649
649
  ############################################################################
650
650
  # Returns list of all collections (tables) as array of choices for usage in select fields.
651
651
  # List is collected from agile_menu.yml files and may not include all collections used in application.
652
- # Currently list is only used for helping defining collection names on agile_permission form.
653
- #
652
+ # Currently list is only used for helping defining collection names on agile_permission form.
653
+ #
654
654
  # Example (as used in forms):
655
655
  # form:
656
656
  # fields:
@@ -714,14 +714,14 @@ def agile_application_menu
714
714
  }
715
715
  "<li>#{agile_link_to(t(option['caption']), option['icon'], opts)}</li>"
716
716
  end
717
- end
717
+ end
718
718
  html += '</ul></li>'
719
719
  end
720
720
  html.html_safe
721
721
  end
722
722
 
723
723
  ############################################################################
724
- # Returns list of directories as array of choices for use in select field
724
+ # Returns list of directories as array of choices for use in select field
725
725
  # on folder permission form. Directory root is determined from ar_site.files_directory field.
726
726
  ############################################################################
727
727
  def agile_choices_for_folders
@@ -735,15 +735,15 @@ end
735
735
  ############################################################################
736
736
  # Returns choices for select input field when choices are generated from
737
737
  # all documents in collection.
738
- #
739
- # Parameters:
738
+ #
739
+ # Parameters:
740
740
  # [model] String. Collection (table) name in lowercase format.
741
741
  # [name] String. Field name containing description text.
742
742
  # [id] String. Field name containing id field. Default is '_id'
743
743
  # [options] Hash. Various options. Currently site: (:only, :with_nil, :all) is used.
744
744
  # Will return only documents belonging to current site, also with site not defined,
745
745
  # or all documents.
746
- #
746
+ #
747
747
  # Example (as used in forms):
748
748
  # 50:
749
749
  # name: agile_poll_id
@@ -755,7 +755,7 @@ def agile_choices_for(model, name, id = 'id', options = {})
755
755
  qry = model.select(id, name)
756
756
  if (param = options[:site])
757
757
  sites = [agile_get_site.id] unless param == :all
758
- sites << nil if param == :with_nil
758
+ sites << nil if param == :with_nil
759
759
  qry = qry.where(ar_site_id: sites) if sites
760
760
  end
761
761
  qry = qry.where(active: true) if model.has_attribute?(:active)
@@ -763,9 +763,9 @@ def agile_choices_for(model, name, id = 'id', options = {})
763
763
  end
764
764
 
765
765
  ############################################################################
766
- # Returns list of choices for selection top level menu on agile_page form. Used for defining which
766
+ # Returns list of choices for selection top level menu on agile_page form. Used for defining which
767
767
  # top level menu will be highlited when page is displayed.
768
- #
768
+ #
769
769
  # Example (as used in forms):
770
770
  # 20:
771
771
  # name: menu_id
@@ -775,15 +775,15 @@ end
775
775
  def agile_choices_for_menu
776
776
  menu_class = agile_get_site.menu_class
777
777
  menu_class = 'ArMenu' if menu_class.blank?
778
- klass = menu_class.classify.constantize
778
+ klass = menu_class.classify.constantize
779
779
  klass.choices_for_menu(agile_get_site)
780
780
  end
781
781
 
782
782
  ############################################################################
783
- # Will add data to record cookie. Record cookie is used to preload some
784
- # data on next create action. Create action will look for cookies[:record] and
783
+ # Will add data to record cookie. Record cookie is used to preload some
784
+ # data on next create action. Create action will look for cookies[:record] and
785
785
  # if found initialize fields on form with matching name to value found in cookie data.
786
- #
786
+ #
787
787
  # Example:
788
788
  # kukis = {'agile_page.ar_design_id' => @page.ar_design_id,
789
789
  # 'agile_page.agile_menu_id' => @page.menu_id)
@@ -801,21 +801,21 @@ end
801
801
 
802
802
  ############################################################################
803
803
  # Will check if user roles allow user to view data in document with defined access_policy.
804
- #
804
+ #
805
805
  # Parameters:
806
806
  # [ctrl] Controller object or object which holds methods to access environment. For example @env
807
807
  # when called from renderer.
808
- # [policy_id] Document or documents policy_id field value required to view data. Method will automatically
808
+ # [policy_id] Document or documents policy_id field value required to view data. Method will automatically
809
809
  # check if parameter send has policy_id field defined and use value of that field.
810
810
  #
811
811
  # Example:
812
- # can_view, message = agile_user_can_view(@env, @page)
812
+ # can_view, message = agile_user_can_view(@env, @page)
813
813
  # # or
814
814
  # can_view, message = agile_user_can_view(@env, @page.policy_id)
815
815
  # return message unless can_view
816
816
  #
817
817
  # Returns:
818
- # True if access_policy allows user to view data.
818
+ # True if access_policy allows user to view data.
819
819
  # False and message from policy that is blocking view if access is not allowed.
820
820
  ############################################################################
821
821
  def agile_user_can_view(ctrl, policy_id)
@@ -870,12 +870,12 @@ end
870
870
  # [roles] Array of roles that will be searched. Default session[:user_roles].
871
871
  #
872
872
  # Example:
873
- # if agile_user_has_role?('decision_maker', session[:user_id), session[:user_roles])
873
+ # if agile_user_has_role?('decision_maker', session[:user_id), session[:user_roles])
874
874
  # do_something_important
875
875
  # end
876
876
  #
877
877
  # Returns:
878
- # Boolean. True if user has required role.
878
+ # Boolean. True if user has required role.
879
879
  ####################################################################
880
880
  def agile_user_has_role?( role, user = nil, roles = nil )
881
881
  roles = _origin.session[:user_roles] if roles.nil?
@@ -892,11 +892,11 @@ end
892
892
  ####################################################################
893
893
  # Returns true if parameter has value of 0, false, no, none or -.
894
894
  # Returns value of default if parameter has nil value.
895
- #
895
+ #
896
896
  # Parameters:
897
- # [what] String/boolean/Integer.
897
+ # [what] String/boolean/Integer.
898
898
  # [default] Default value when what has value of nil. False by default.
899
- #
899
+ #
900
900
  # Example:
901
901
  # agile_dont?('none') # => true
902
902
  # agile_dont?('-') # => true
@@ -910,10 +910,10 @@ end
910
910
  ############################################################################
911
911
  # Truncates string length maximal to the size required and takes care, that words are not broken in middle.
912
912
  # Used for output text summary with texts that can be longer then allowed space.
913
- #
913
+ #
914
914
  # Parameters:
915
915
  # [string] String of any size.
916
- # [size] Maximal size of the string to be returned.
916
+ # [size] Maximal size of the string to be returned.
917
917
  #
918
918
  # Example:
919
919
  # agile_limit_string(description, 100)
@@ -933,16 +933,16 @@ end
933
933
  # Returns key defined in ArBigTable as array of choices for use in select fields.
934
934
  # ArBigTable can be used like a key/value store for all kind of predefined values
935
935
  # which can be linked to site and or locale.
936
- #
936
+ #
937
937
  # Parameters:
938
938
  # [key] String. Key name to be searched in agile_big_tables documents.
939
- #
939
+ #
940
940
  # Example:
941
941
  # 10:
942
942
  # name: category
943
943
  # type: select
944
944
  # eval: agile_big_table_choices 'categories_for_page' # as used on form
945
- #
945
+ #
946
946
  # Returns:
947
947
  # Array of choices ready for select field.
948
948
  ############################################################################
@@ -965,12 +965,12 @@ end
965
965
  # Will return html code required for load AgileRails form into iframe. If parameters
966
966
  # are passed to method iframe url will have initial value and thus enabling automatic form
967
967
  # load on page display.
968
- #
968
+ #
969
969
  # Parameters:
970
970
  # [table] String: Collection (table) name used to load initial form.
971
971
  # [opts] Hash: Optional parameters which define url for loading AgileRails form.
972
972
  # These parameters are :action, :oper, :table, :form_name, :id, :readonly
973
- #
973
+ #
974
974
  # Example:
975
975
  # # just iframe code
976
976
  # <%= agile_edit_frame(nil) %>
@@ -978,13 +978,13 @@ end
978
978
  # <%= agile_edit_frame('note', iframe: 'iframe_name') %>
979
979
  # # on register collection use reg_adresses form_name to display data with id @register.id
980
980
  # <%= agile_edit_frame('register', action: :show, form_name: 'reg_adresses', readonly: 1, id: @register.id ) %>
981
- #
981
+ #
982
982
  # Returns:
983
983
  # Html code for edit iframe
984
984
  ########################################################################
985
985
  def agile_edit_frame(table, opts = {})
986
986
  iframe_name = opts[:iframe] || 'iframe_edit'
987
- if params.to_unsafe_h.size > 2 && table # controller, action, path is minimal
987
+ if params.to_unsafe_h.size > 2 && table # controller, action, path is minimal
988
988
  params[:controller] = :agile
989
989
  params[:action] = params[:oper] == 'edit' ? 'edit' : 'index'
990
990
  params[:action] = opts[:action] unless params[:oper]
@@ -1035,19 +1035,20 @@ def agile_internal_var(object, var_name, current_record = nil)
1035
1035
  klas = clas.classify.constantize
1036
1036
  # call method. Error will be caught below.
1037
1037
  klas.send(method_name)
1038
+ when 'eval' then eval("_origin.#{var_name}")
1038
1039
  else
1039
1040
  'VARIABLE: UNKNOWN OBJECT'
1040
1041
  end
1041
1042
  rescue Exception => e
1042
- Rails.logger.debug "\nagile_internal_var. Runtime error. #{e.message}\n"
1043
- Rails.logger.debug(e.backtrace.join($/)) if Rails.env.development?
1043
+ Rails.logger.error "\nagile_internal_var. Runtime error. #{e.message}\n"
1044
+ Rails.logger.error(e.backtrace.join($/)) if Rails.env.development?
1044
1045
  'VARIABLE: ERROR'
1045
1046
  end
1046
1047
  end
1047
1048
 
1048
1049
  ########################################################################
1049
1050
  # Will return formated code for embedding json+ld data into page
1050
- #
1051
+ #
1051
1052
  # Returns:
1052
1053
  # HTML data to be embedded into page header
1053
1054
  #######################################################################
@@ -1078,7 +1079,7 @@ end
1078
1079
 
1079
1080
  ########################################################################
1080
1081
  # Will return meta data for SEO optimizations
1081
- #
1082
+ #
1082
1083
  # Returns:
1083
1084
  # HTML data to be embedded into page header
1084
1085
  #######################################################################
@@ -1096,7 +1097,7 @@ end
1096
1097
  ########################################################################
1097
1098
  # Will add a meta tag to internal hash structure. If meta tag already exists it
1098
1099
  # will be overwritten.
1099
- #
1100
+ #
1100
1101
  # Parameters:
1101
1102
  # [name] String: meta name
1102
1103
  # [content] String: meta content
@@ -1127,9 +1128,9 @@ end
1127
1128
 
1128
1129
  #######################################################################
1129
1130
  # Will return alt image option when text is provided. When text is blank
1130
- # it will extract alt name from picture file_name. This method returns just
1131
+ # it will extract alt name from picture file_name. This method returns just
1131
1132
  # alt name.
1132
- #
1133
+ #
1133
1134
  # Parameters:
1134
1135
  # [file_name] String: Filename of a picture
1135
1136
  # [text] String: Alt text name
@@ -33,7 +33,7 @@ module AgileCategoryHelper
33
33
  def categories_as_tree
34
34
  head = '<div id="catagories-as-tree"><ul><li data-id="nil"><span class="mi-o mi-home"></span>'
35
35
  data = ArCategory.where(parent: nil).order(order: :asc).to_a
36
- (head + html_for_category_tree(data) + '</li></ul></div>' + js_for_category_tree).html_safe
36
+ "#{head}#{html_for_category_tree(data)}</li></ul></div>#{js_for_category_tree}".html_safe
37
37
  end
38
38
 
39
39
  private
@@ -51,7 +51,7 @@ def html_for_category_tree(data)
51
51
  html += html_for_category_tree(children) if children.size > 0
52
52
  html += '</li>'
53
53
  end
54
- html + '</ul>'
54
+ "#{html}</ul>"
55
55
  end
56
56
 
57
57
  ####################################################################
@@ -242,18 +242,17 @@ end
242
242
  # if value is found in values. If not it will report error and set value to default.
243
243
  # Subroutine of agile_fields_for_tab.
244
244
  ############################################################################
245
- def agile_check_and_default(value, default, values = nil) #:nodoc:
245
+ def agile_check_and_default(value, default, values = nil) # :nodoc:
246
246
  return default if value.nil?
247
+
247
248
  # check if value is within allowed values
248
- if values
249
- if !values.index(value)
250
- # parameters should be in downcase. Check downcase version.
251
- if n = values.index(value.downcase)
252
- return values[n]
253
- else
254
- logger.error("AgileRails Forms: Value #{value} not within values [#{values.join(',')}]. Default #{default} used!")
255
- return default
256
- end
249
+ if values && !values.index(value)
250
+ # parameters should be in downcase
251
+ if n = values.index(value.downcase)
252
+ return values[n]
253
+ else
254
+ logger.error("AgileRails Forms: Value #{value} not within values [#{values.join(',')}]. Default #{default} used!")
255
+ return default
257
256
  end
258
257
  end
259
258
  value
@@ -263,12 +262,12 @@ end
263
262
  # Creates input fields defined in form options
264
263
  ############################################################################
265
264
  def agile_fields_for_form
266
- html = "<div id='data_fields' " + (@form['form']['height'] ? "style=\"height: #{@form['form']['height']}px;\">" : '>')
265
+ html = '<div id="data_fields" ' + (@form['form']['height'] ? "style=\"height: #{@form['form']['height']}px;\">" : '>')
267
266
  @js ||= ''
268
267
  @css ||= ''
269
268
  # fields
270
269
  if (form_fields = @form['form']['fields'])
271
- html += agile_input_form(form_fields) + '</div>'
270
+ html += "#{agile_input_form(form_fields)}</div>"
272
271
  elsif @form['form']['tabs'] #tabs
273
272
  html = agile_tabs_form()
274
273
  end
@@ -277,7 +276,7 @@ def agile_fields_for_form
277
276
  # add form time stamp to prevent double form submit
278
277
  html += hidden_field(nil, :form_time_stamp, value: Time.now.to_i)
279
278
  # add javascript code if defined by form
280
- @js += "\n#{@form['script']} #{@form['js']}"
279
+ @js += "\n#{@form['script']} #{@form['js']}"
281
280
  @css += "\n#{@form['css']}\n#{@form['form']['css']}"
282
281
  html.html_safe
283
282
  end
@@ -307,7 +306,7 @@ def agile_head_for_form
307
306
  elsif options['name'] == caption
308
307
  t_label_for_field(options['name'], options['name'].capitalize.gsub('_',' ') )
309
308
  else
310
- t(caption, caption)
309
+ t(caption, caption)
311
310
  end
312
311
  # Field value
313
312
  begin
@@ -468,6 +467,7 @@ def agile_input_form(fields_on_tab) #:nodoc:
468
467
  end
469
468
  # label
470
469
  field_html, label, help = agile_field_label_help(options)
470
+ no_help = help.blank? ? ' no-help' : ''
471
471
  label = nil if agile_dont?(options['caption'])
472
472
  # Line separator
473
473
  html += agile_top_bottom_line(:top, options)
@@ -485,7 +485,7 @@ def agile_input_form(fields_on_tab) #:nodoc:
485
485
  end
486
486
  label = label.nil? ? '' : %(<label for="record_#{options['name']}">#{label} </label>)
487
487
  %(
488
- <div class="ar-form-label-top ar-align-left ar-width-#{data_width}" title="#{help}">
488
+ <div class="ar-form-label-top ar-align-left ar-width-#{data_width}#{no_help}" title="#{help}">
489
489
  #{label}
490
490
  <div id="td_record_#{options['name']}">#{field_html}</div>
491
491
  </div> )
@@ -504,7 +504,7 @@ def agile_input_form(fields_on_tab) #:nodoc:
504
504
  end
505
505
  help.gsub!('<br>',"\n") if help.present?
506
506
  %(
507
- <div class="ar-form-label ar-align-right ar-width-#{label_width}" title="#{help}">
507
+ <div class="ar-form-label ar-align-right ar-width-#{label_width}#{no_help}" title="#{help}">
508
508
  <label for="record_#{options['name']}">#{label} </label>
509
509
  </div>
510
510
  <div id="td_record_#{options['name']}" class="ar-form-field ar-width-#{data_width}">#{field_html}</div>
@@ -52,10 +52,8 @@ def agile_actions_for_index
52
52
 
53
53
  html_left, html_right = '', ''
54
54
  # Remove actions settings and sort
55
- only_actions = []
56
- actions.each { |key, value| only_actions << [key, value] if key.instance_of?(Integer) }
57
- only_actions.sort_by!(&:first)
58
- only_actions.each do |key, options|
55
+ only_actions = actions.select{ |k, v| k.instance_of?(Integer) }.sort_by(&:first).map(&:last)
56
+ only_actions.each do |options|
59
57
  next if options.nil? # must be
60
58
 
61
59
  url = @form_params.clone
@@ -74,45 +72,48 @@ def agile_actions_for_index
74
72
  # html link options
75
73
  html_options = yaml['html'] || {}
76
74
  html_options['title'] = yaml['title'] if yaml['title']
77
- case action
78
- # new
79
- when 'new'
80
- caption = yaml['caption'] || 'agile.new'
81
- html_options['class'] = 'ar-link'
82
- html_left += "<li>#{agile_link_to(caption, 'add', url, html_options)}</li>"
83
- # filter
84
- when 'filter'
85
- # filter off is not present
86
- no_off = session.dig(:filters, @form['table'], :filter, :no_off)
87
- next if no_off
88
-
89
- url = ''
90
- if session.dig(:filters, @form['table'], :filter)
91
- url = url_for(controller: :agile, action: :run, control: 'agile.filter_off', t: @form['table'], f: AgileHelper.form_param(params))
92
- end
93
- html_right += %(
75
+ html = case action
76
+ # new
77
+ when 'new'
78
+ caption = yaml['caption'] || 'agile.new'
79
+ html_options['class'] = 'ar-link'
80
+ "<li>#{agile_link_to(caption, 'add', url, html_options)}</li>"
81
+
82
+ # filter
83
+ when 'filter'
84
+ # filter off is not present
85
+ no_off = session.dig(:filters, @form['table'], :filter, :no_off)
86
+ next if no_off
87
+
88
+ url = ''
89
+ if session.dig(:filters, @form['table'], :filter)
90
+ url = url_for(controller: :agile, action: :run, control: 'agile.filter_off', t: @form['table'], f: AgileHelper.form_param(params))
91
+ end
92
+ yaml['position'] ||= 'right'
93
+ %(
94
94
  <li>
95
95
  <div class="ar-filter" title="#{ArFilter.title_for_filter_off(session.dig(:filters, @form['table']))}" data-url="#{url.html_safe}">
96
96
  #{mi_icon(url.blank? ? 'search' : 'filter_alt_off') }#{ArFilter.filter_menu(self).html_safe}
97
97
  </div>
98
98
  </li>#{ArFilter.get_filter_input_field(self)}).html_safe
99
99
 
100
- when 'close'
101
- html_left += %(<li><div class="ar-link" onclick="window.close();"'>#{mi_icon('close')} #{t('agile.close')}</div></li>)
102
-
103
- when 'back'
104
- html_left += %(<li><div class="ar-link" onclick="history.back();"'>#{mi_icon('arrow_back')} #{t('agile.back')}</div></li>)
105
-
106
- # menu
107
- when 'menu'
108
- code = if options['caption']
109
- caption = "#{t(options['caption'], options['caption'])}&nbsp;#{mi_icon('caret-down')}"
110
- caption + agile_process_eval(options['eval'], self)
111
- else # when caption is false, provide own actions
112
- agile_process_eval(options['eval'], self)
113
- end
114
- html_left += %(<li><div class="ar-link">#{code}</div></li>)
115
-
100
+ # close
101
+ when 'close'
102
+ %(<li><div class="ar-link" onclick="window.close();"'>#{mi_icon('close')} #{t('agile.close')}</div></li>)
103
+
104
+ # back
105
+ when 'back'
106
+ %(<li><div class="ar-link" onclick="history.back();"'>#{mi_icon('arrow_back')} #{t('agile.back')}</div></li>)
107
+
108
+ # menu
109
+ when 'menu'
110
+ code = if options['caption']
111
+ caption = "#{t(options['caption'], options['caption'])}&nbsp;#{mi_icon('caret-down')}"
112
+ caption + agile_process_eval(options['eval'], self)
113
+ else # when caption is false, provide own actions
114
+ agile_process_eval(options['eval'], self)
115
+ end
116
+ %(<li><div class="ar-link">#{code}</div></li>)
116
117
  =begin
117
118
  # reorder
118
119
  when action == 'reorder' then
@@ -124,35 +125,42 @@ def agile_actions_for_index
124
125
  agile_link_to( caption, 'reorder', parms, method: :delete )
125
126
  =end
126
127
 
127
- when 'script'
128
- html_left += agile_script_action(options)
128
+ when 'script'
129
+ agile_script_action(options)
129
130
 
130
- when 'field'
131
- if yaml['position'] == 'left'
132
- html_left += agile_field_action(yaml)
133
- else
134
- html_right += agile_field_action(yaml)
135
- end
131
+ when 'field'
132
+ yaml['position'] ||= 'right'
133
+ agile_field_action(yaml)
136
134
 
137
- when 'ajax', 'link', 'window', 'popup', 'submit'
138
- html_left += agile_link_ajax_window_submit_action(options, nil)
135
+ when 'ajax', 'link', 'window', 'popup', 'submit'
136
+ agile_link_ajax_window_submit_action(options, nil)
139
137
 
140
- # sort
141
- when 'sort'
142
- choices = [%w[id id]]
143
- @form['index']['sort']&.split(',')&.each do |e|
144
- e.strip!
145
- choices << [ t("helpers.label.#{@form['table']}.#{e}"), e ]
146
- end
147
- data = mi_icon('sort') + select('sort', 'sort', choices, { include_blank: true },
148
- { class: 'ar-sort-select', 'data-table' => @form['table'], 'data-form' => AgileHelper.form_param(params)} )
149
- html_right += %(<li title="#{t('agile.sort')}"><div class="ar-sort">#{data}</li>)
138
+ # sort
139
+ when 'sort'
140
+ yaml['position'] ||= 'right'
141
+ choices = [%w[id id]]
142
+ @form['index']['sort']&.split(',')&.each do |e|
143
+ e.strip!
144
+ choices << [t("helpers.label.#{@form['table']}.#{e}"), e]
145
+ end
146
+ data = mi_icon('sort') + select('sort', 'sort', choices, { include_blank: true },
147
+ { class: 'ar-sort-select', 'data-table' => @form['table'],
148
+ 'data-form' => AgileHelper.form_param(params)})
149
+ %(<li title="#{t('agile.sort')}"><div class="ar-sort">#{data}</li>)
150
+
151
+ # link
152
+ else
153
+ caption = agile_get_caption(yaml) || t("agile.#{action}")
154
+ icon = yaml['icon'] || action
155
+ html_options['class'] = 'ar-link'
156
+ code = agile_link_to(caption, icon, url, html_options)
157
+ html_left += %(<li>#{code}</li>)
158
+ end
159
+ yaml['position'] ||= 'left'
160
+ if yaml['position'] == 'left'
161
+ html_left += html
150
162
  else
151
- caption = agile_get_caption(yaml) || t("agile.#{action}")
152
- icon = yaml['icon'] || action
153
- html_options['class'] = 'ar-link'
154
- code = agile_link_to(caption, icon, url, html_options)
155
- html_left += %(<li>#{code}</li>)
163
+ html_right += html
156
164
  end
157
165
  end
158
166
 
@@ -166,7 +174,7 @@ def agile_actions_for_index
166
174
  </div>
167
175
  <div style="clear: both;"></div>
168
176
  </form>
169
- ).html_safe
177
+ ).html_safe
170
178
  end
171
179
 
172
180
  ############################################################################
@@ -542,7 +550,6 @@ def agile_process_eval(evaluate, parameters)
542
550
 
543
551
  if method
544
552
  klass = clas.camelize.constantize rescue nil
545
- p klass, clas
546
553
  return klass.send(method, *parameters) if klass&.respond_to?(method)
547
554
  end
548
555
  agile_log_exception(nil, "#{evaluate} not defined!")
@@ -79,7 +79,6 @@ end
79
79
  # DateTimePicker get_data method.
80
80
  ###########################################################################
81
81
  def self.get_data(params, name)
82
- p params,'----------------------------------------------------'
83
82
  t = params['record'][name] ? params['record'][name].to_datetime : nil
84
83
  t ? Time.new(t.year, t.month, t.day, t.hour, t.min) : nil
85
84
  end
@@ -83,15 +83,9 @@ def validate_image_values
83
83
  end
84
84
  end
85
85
 
86
- #########################################################################
87
- # Will return first available image starting from small up
88
- #########################################################################
89
86
  def first_available_image
90
- image = %w[o s m l].each do |size|
91
- field = "size_#{size}"
92
- value = send(field)
93
- return "#{id}-#{size}.#{img_type}" if value.present?
94
- end
87
+ image = %w[o s m l].find { send("size_#{_1}").present? }
88
+ image ? "#{id}-#{image}.#{img_type}" : nil
95
89
  end
96
90
 
97
91
  #########################################################################
@@ -38,8 +38,7 @@
38
38
  ##############################################################################
39
39
  class ArSetup < ApplicationRecord
40
40
 
41
- attr_reader :my_data
42
- attr_reader :my_fields
41
+ attr_reader :my_data, :my_fields
43
42
 
44
43
  validates_length_of :name, minimum: 3
45
44
 
@@ -97,12 +96,10 @@ def [](*keys)
97
96
  end
98
97
 
99
98
  ##############################################################################
100
- # Will return true if setting is defined on the form
99
+ # Should always respond as true
101
100
  ##############################################################################
102
101
  def respond_to?(field_name)
103
- return true #if my_fields[field_name.to_s]
104
-
105
- super.respond_to?(field_name)
102
+ true
106
103
  end
107
104
 
108
105
  ##############################################################################
@@ -26,8 +26,8 @@
26
26
  # is required in browser.
27
27
  ########################################################################
28
28
  class ArPollRenderer
29
-
30
- include AgileCommonHelper
29
+
30
+ include AgileCommonHelper
31
31
  include AgileApplicationHelper
32
32
  include ActionView::Helpers::FormHelper # for form helpers
33
33
  include ActionView::Helpers::FormOptionsHelper # for select helper
@@ -64,13 +64,13 @@ def do_one_item(poll, yaml)
64
64
  yaml['html'] ||= {}
65
65
  yaml['html']['required'] = true
66
66
  else
67
- text += " &nbsp;" if poll.display == 'lr' and !yaml['type'].match(/submit_tag|link_to/)
67
+ text += ' &nbsp;' if poll.display == 'lr' and !yaml['type'].match(/submit_tag|link_to/)
68
68
  end
69
69
 
70
70
  # Just add text if comment and go to next one
71
71
  if yaml['type'] == 'comment'
72
72
  html += if poll.display == 'lr'
73
- "<div class='row-div'><div class='ar-form-label poll-data-text comment'>#{text}</div></div>"
73
+ "<div class='row-div'><div class='ar-form-label poll-data-text comment no_help'>#{text}</div></div>"
74
74
  else
75
75
  "<div class='poll-data-text comment'>#{text}</div>"
76
76
  end
@@ -97,17 +97,17 @@ def do_one_item(poll, yaml)
97
97
  # create form_field object and retrieve html code
98
98
  clas_string = yaml['type'].camelize
99
99
  field_html = if AgileFormFields.const_defined?(clas_string)
100
- clas = AgileFormFields.const_get(clas_string)
101
- field = clas.new(@env, @record, yaml).render
102
- @part_js += field.js
103
- field.html
104
- else # error string
105
- "Error: Code for field type #{yaml['type']} not defined!"
106
- end
100
+ clas = AgileFormFields.const_get(clas_string)
101
+ field = clas.new(@env, @record, yaml).render
102
+ @part_js += field.js
103
+ field.html
104
+ else # error string
105
+ "Error: Code for field type #{yaml['type']} not defined!"
106
+ end
107
107
 
108
108
  if yaml['type'].match(/submit_tag|link_to/)
109
109
  # There can be more than one links on form. End the data at first link or submit.
110
- if !@end_of_data
110
+ unless @end_of_data
111
111
  html += (poll.display == 'lr' ? "</div><br>\n" : "</div>\n")
112
112
  # captcha
113
113
  if poll.captcha_type.to_s.size > 1
@@ -124,12 +124,14 @@ def do_one_item(poll, yaml)
124
124
  # other fields
125
125
  else
126
126
  html += case
127
- when poll.display == 'lr' then
128
- "<div class='row-div'><div class='ar-form-label poll-data-text lr #{yaml['class']}'>#{text}</div><div class='poll-data-field td #{yaml['class']}'>#{field_html}</div></div>\n"
127
+ when poll.display == 'lr'
128
+ "<div class='row-div'><div class='ar-form-label poll-data-text lr #{yaml['class']} no_help'>#{text}</div>
129
+ <div class='poll-data-field td #{yaml['class']}'>#{field_html}</div></div>\n"
129
130
  when poll.display == 'td' then
130
- "<div class='poll-data-text td #{yaml['class']}'>#{text}</div><div class='poll-data-field td #{yaml['class']}'>#{field_html}#{yaml['separator']}</div>\n"
131
+ "<div class='poll-data-text td #{yaml['class']}'>#{text}</div>
132
+ <div class='poll-data-field td #{yaml['class']}'>#{field_html}#{yaml['separator']}</div>\n"
131
133
  else
132
- "<div class='poll-data-field in #{yaml['class']}'>#{field_html}#{yaml['separator']}</div>\n"
134
+ "<div class='poll-data-field in #{yaml['class']}'>#{field_html}#{yaml['separator']}</div>\n"
133
135
  end
134
136
  end
135
137
  end
@@ -216,6 +218,7 @@ def default
216
218
  if poll.form.to_s.size < 10
217
219
  poll.ar_poll_items.order(order: 'asc').each do |item|
218
220
  next unless item.active # disabled items
221
+
219
222
  # convert options to yaml
220
223
  begin
221
224
  yaml = YAML.load(item.options) || {}
@@ -242,14 +245,14 @@ def default
242
245
  end
243
246
  # hide some fields usefull as parameters
244
247
  html += @env.hidden_field_tag('return_to', @opts[:return_to] || @env.params[:return_to] || @env.request.url)
245
- html += @env.hidden_field_tag('return_to_error', @env.request.url )
248
+ html += @env.hidden_field_tag('return_to_error', @env.request.url)
246
249
  html += @env.hidden_field_tag('poll_id', poll_id )
247
- html += @env.hidden_field_tag('page_id', @env.page.id )
250
+ html += @env.hidden_field_tag('page_id', @env.page.id)
248
251
  # Add javascript code
249
252
  html += @env.javascript_tag(@part_js + poll.js.to_s)
250
- html += "</form></div>"
253
+ html += '</form></div>'
251
254
  html += '</div>' if @opts[:div]
252
-
255
+
253
256
  @part_css = poll.css
254
257
  html
255
258
  end
data/lib/agile/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2023+ Damjan Rems
2
+ # Copyright (c) 2025+ 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
@@ -23,5 +23,5 @@
23
23
 
24
24
  # Agile gem version
25
25
  module Agile # :nodoc:
26
- VERSION = '0.0.0.2'.freeze
26
+ VERSION = '0.0.0.3'.freeze
27
27
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agile_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.2
4
+ version: 0.0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damjan Rems
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-18 00:00:00.000000000 Z
10
+ date: 2025-09-26 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: jquery-rails