fae-rails 1.7.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -2
  3. data/Rakefile +0 -3
  4. data/app/assets/images/fae/tutorial_model_location.png +0 -0
  5. data/app/assets/javascripts/fae/_deploy.js +198 -0
  6. data/app/assets/javascripts/fae/_modals.js +94 -0
  7. data/app/assets/javascripts/fae/_tables.js +11 -25
  8. data/app/assets/javascripts/fae/application.js +4 -2
  9. data/app/assets/javascripts/fae/fae_init.js +0 -4
  10. data/app/assets/javascripts/fae/form/_ajax.js +26 -7
  11. data/app/assets/javascripts/fae/form/_cancel.js +1 -0
  12. data/app/assets/javascripts/fae/form/_filtering.js +34 -0
  13. data/app/assets/javascripts/fae/form/_form.js +1 -0
  14. data/app/assets/javascripts/fae/form/_form_manager.js +295 -0
  15. data/app/assets/javascripts/fae/form/_slugger.js.erb +2 -2
  16. data/app/assets/javascripts/fae/form/_validator.js +24 -14
  17. data/app/assets/javascripts/fae/form/inputs/_color.js +2 -1
  18. data/app/assets/javascripts/fae/form/inputs/_select.js +5 -2
  19. data/app/assets/javascripts/fae/navigation/_language.js +1 -1
  20. data/app/assets/javascripts/fae/navigation/_navigation.js +9 -21
  21. data/app/assets/javascripts/fae/navigation/_subnav_highlighter.js +7 -41
  22. data/app/assets/javascripts/fae/vendor/jqColorPicker.min.js +0 -1
  23. data/app/assets/stylesheets/fae/base.scss +7 -8
  24. data/app/assets/stylesheets/fae/globals/imports/_variables.scss +1 -2
  25. data/app/assets/stylesheets/fae/globals/layout/_base.scss +7 -2
  26. data/app/assets/stylesheets/fae/globals/layout/_content-header.scss +17 -31
  27. data/app/assets/stylesheets/fae/globals/navigation/_header.scss +2 -2
  28. data/app/assets/stylesheets/fae/globals/navigation/_multi-col-subnav.scss +50 -0
  29. data/app/assets/stylesheets/fae/modules/_buttons.scss +11 -0
  30. data/app/assets/stylesheets/fae/modules/_deploy.scss +25 -0
  31. data/app/assets/stylesheets/fae/modules/_modal.scss +25 -0
  32. data/app/assets/stylesheets/fae/modules/_toggles.scss +39 -23
  33. data/app/assets/stylesheets/fae/modules/forms/_asset-actions.scss +1 -1
  34. data/app/assets/stylesheets/fae/modules/forms/_base.scss +1 -1
  35. data/app/assets/stylesheets/fae/modules/forms/_checkbox.scss +1 -1
  36. data/app/assets/stylesheets/fae/modules/forms/_date.scss +16 -0
  37. data/app/assets/stylesheets/fae/modules/forms/_form-manager.scss +82 -0
  38. data/app/assets/stylesheets/fae/modules/forms/_radio.scss +1 -1
  39. data/app/assets/stylesheets/fae/modules/forms/_select.scss +7 -6
  40. data/app/assets/stylesheets/fae/modules/forms/_simple-mde.scss +1 -1
  41. data/app/assets/stylesheets/fae/modules/forms/_textarea.scss +1 -1
  42. data/app/assets/stylesheets/fae/modules/tables/_filters.scss +4 -0
  43. data/app/assets/stylesheets/fae/pages/_home.scss +18 -0
  44. data/app/assets/stylesheets/fae/pages/_login.scss +4 -0
  45. data/app/controllers/fae/application_controller.rb +22 -1
  46. data/app/controllers/fae/base_controller.rb +6 -2
  47. data/app/controllers/fae/deploy_controller.rb +24 -0
  48. data/app/controllers/fae/deploy_hooks_controller.rb +71 -0
  49. data/app/controllers/fae/form_managers_controller.rb +19 -0
  50. data/app/controllers/fae/options_controller.rb +1 -0
  51. data/app/controllers/fae/pages_controller.rb +3 -2
  52. data/app/controllers/fae/static_pages_controller.rb +6 -1
  53. data/app/controllers/fae/users_controller.rb +19 -1
  54. data/app/controllers/fae/utilities_controller.rb +18 -6
  55. data/app/helpers/fae/application_helper.rb +27 -2
  56. data/app/helpers/fae/form_helper.rb +40 -8
  57. data/app/helpers/fae/nested_form_helper.rb +2 -2
  58. data/app/helpers/fae/view_helper.rb +99 -43
  59. data/app/models/concerns/fae/base_model_concern.rb +10 -7
  60. data/app/models/concerns/fae/user_concern.rb +10 -1
  61. data/app/models/fae/change.rb +18 -5
  62. data/app/models/fae/deploy_hook.rb +12 -0
  63. data/app/models/fae/file.rb +1 -1
  64. data/app/models/fae/form_manager.rb +24 -0
  65. data/app/models/fae/image.rb +1 -1
  66. data/app/models/fae/option.rb +1 -1
  67. data/app/models/fae/role.rb +1 -1
  68. data/app/models/fae/static_page.rb +11 -2
  69. data/app/models/fae/user.rb +4 -5
  70. data/app/services/fae/netlify_api.rb +197 -0
  71. data/app/uploaders/fae/file_uploader.rb +2 -5
  72. data/app/uploaders/fae/image_uploader.rb +3 -3
  73. data/app/views/devise/unlocks/new.html.slim +5 -9
  74. data/app/views/fae/application/_content_form.html.slim +16 -11
  75. data/app/views/fae/application/_file_uploader.html.slim +11 -3
  76. data/app/views/fae/application/_global_search_results.html.slim +2 -2
  77. data/app/views/fae/application/_header.slim +12 -9
  78. data/app/views/fae/application/_markdown_helper.slim +17 -17
  79. data/app/views/fae/application/_mobilenav.slim +9 -6
  80. data/app/views/fae/application/_user_log.html.slim +2 -2
  81. data/app/views/fae/deploy/index.html.slim +40 -0
  82. data/app/views/fae/deploy_hooks/_form.html.slim +18 -0
  83. data/app/views/fae/deploy_hooks/_table.html.slim +28 -0
  84. data/app/views/fae/deploy_hooks/edit.html.slim +3 -0
  85. data/app/views/fae/deploy_hooks/new.html.slim +3 -0
  86. data/app/views/fae/images/_image_uploader.html.slim +15 -6
  87. data/app/views/fae/options/_form.html.slim +11 -8
  88. data/app/views/fae/pages/activity_log.html.slim +16 -12
  89. data/app/views/fae/pages/disabled_environment.html.slim +2 -2
  90. data/app/views/fae/pages/error404.html.slim +5 -3
  91. data/app/views/fae/pages/home.html.slim +32 -21
  92. data/app/views/fae/setup/first_user.html.slim +3 -3
  93. data/app/views/fae/shared/_form_header.html.slim +37 -33
  94. data/app/views/fae/shared/_index_header.html.slim +3 -2
  95. data/app/views/fae/shared/_nested_table.html.slim +6 -6
  96. data/app/views/fae/shared/_recent_changes.html.slim +6 -6
  97. data/app/views/fae/shared/_shared_nested_table.html.slim +5 -2
  98. data/app/views/fae/static_pages/index.html.slim +2 -2
  99. data/app/views/fae/users/_form.html.slim +8 -12
  100. data/app/views/fae/users/index.html.slim +7 -7
  101. data/app/views/layouts/fae/application.html.slim +1 -0
  102. data/config/deploy.rb +3 -1
  103. data/config/initializers/devise.rb +6 -6
  104. data/config/locales/devise.cs.yml +59 -0
  105. data/config/locales/fae.cs.yml +125 -0
  106. data/config/locales/fae.en.yml +145 -0
  107. data/config/locales/fae.zh-CN.yml +109 -0
  108. data/config/routes.rb +9 -1
  109. data/db/migrate/20140809222030_add_user_table.rb +2 -2
  110. data/db/migrate/20140822224029_create_fae_roles.rb +1 -1
  111. data/db/migrate/20141008180718_create_fae_images_table.rb +1 -1
  112. data/db/migrate/20141017194616_create_fae_options.rb +1 -1
  113. data/db/migrate/20141021181327_create_fae_files.rb +1 -1
  114. data/db/migrate/20141021183047_create_fae_text_areas.rb +1 -1
  115. data/db/migrate/20141021184311_create_fae_pages.rb +1 -1
  116. data/db/migrate/20141105214814_create_fae_text_fields.rb +1 -1
  117. data/db/migrate/20150930224821_create_fae_changes.rb +1 -1
  118. data/db/migrate/20190925153222_create_fae_form_managers.rb +11 -0
  119. data/db/migrate/20220118192729_create_fae_publish_hooks.rb +10 -0
  120. data/db/migrate/20220128133730_rename_publish_hooks.rb +5 -0
  121. data/db/migrate/20220202153607_add_position_to_deploy_hooks.rb +6 -0
  122. data/lib/fae/options.rb +4 -2
  123. data/lib/fae/version.rb +1 -1
  124. data/lib/generators/fae/base_generator.rb +62 -8
  125. data/lib/generators/fae/nested_index_scaffold_generator.rb +1 -1
  126. data/lib/generators/fae/nested_scaffold_generator.rb +16 -2
  127. data/lib/generators/fae/page_generator.rb +8 -0
  128. data/lib/generators/fae/scaffold_generator.rb +1 -1
  129. data/lib/generators/fae/templates/assets/fae.js +1 -1
  130. data/lib/generators/fae/templates/controllers/nested_scaffold_controller.rb +14 -0
  131. data/lib/generators/fae/templates/graphql/graphql_page_type.rb +17 -0
  132. data/lib/generators/fae/templates/graphql/graphql_type.rb +13 -0
  133. data/lib/generators/fae/templates/initializers/fae.rb +16 -1
  134. data/lib/generators/fae/templates/views/_form.html.slim +11 -4
  135. data/lib/generators/fae/templates/views/_form_index_nested.html.slim +15 -1
  136. data/lib/generators/fae/templates/views/_form_nested.html.slim +19 -2
  137. data/lib/generators/fae/templates/views/index_nested.html.slim +1 -0
  138. data/lib/generators/fae/templates/views/static_page_form.html.slim +14 -3
  139. metadata +70 -47
  140. data/app/views/fae/shared/_form_buttons.html.slim +0 -11
  141. data/app/views/fae/shared/_nested_table_advanced.html.slim +0 -18
  142. data/lib/sub_test_task_patch.rb +0 -129
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2efad2fc9feedd56fc9ec582e9ac519e6f7c0a8b
4
- data.tar.gz: 1f3079cb3d1143a955289d8add21a72a7b6772a4
3
+ metadata.gz: 627ef0b4fdd41a840e63ef13d5816702d67109e3
4
+ data.tar.gz: 2ee2bdb673debee82c40eb3064d44fdaf0143515
5
5
  SHA512:
6
- metadata.gz: ccf4b94fe96cdc89fe3119ba65ee96584dea2cacbc6dc15a7b8518a90a8053f1481c82201d7165883b3ad57bfb993abe0d5368242ae2e18750a8ec3d5a29bf8b
7
- data.tar.gz: 5f3702e59f1583fac3bcddada5aff0c324c2a9464c4071584256995ccbed06e4ae8329f14b1bcb8e5667d500a50b1bb199d449d8a5555a07c53ae6c2df941a3d
6
+ metadata.gz: 3b31bb1dce450aecd010f337e851fb895ef86c4ccbcc8983d77e7d594e72a28e457a9966d79f238963d8e45fcb32a539167cd2e29666d2c6fb8a7b908cf8e41b
7
+ data.tar.gz: 0d9775d7d639bc6fbe66ffbfb40ca5aaf1dccf99344c6160fbbdc6e2f7116e57f42bcc0da4b81345d7f504c2fa89fb206bc9235393f9913f14f3955fe6745e16
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  Like many Rails CMS engines, Fae delivers all the basics to get you up and running quickly: authentication, authorization, a sleek UI, form helpers, image processing and workflows. But unlike other engines, Fae's generated models, controllers, and views are built to customize and scale.
9
9
 
10
- Fae supports Rails 4.1 to 5.0. We are currently working on Rails 5.1 support.
10
+ Fae 2.0 supports Rails 5.0 to 5.2, support for Rails 4.x is deprecated as of Fae 2.0.
11
11
 
12
12
  ## Installation
13
13
 
@@ -27,7 +27,7 @@ $ rails g fae:install
27
27
 
28
28
  ## Documentation
29
29
 
30
- For full documentation visit:
30
+ For full documentation visit:
31
31
  https://www.faecms.com/documentation
32
32
 
33
33
  ### Topics
@@ -57,10 +57,13 @@ https://www.faecms.com/documentation
57
57
  * [Change Tracker](docs/features/change_tracker.md)
58
58
  * [Slugger](docs/features/slugger.md)
59
59
  * [Disabling Environments](docs/features/disable_envs.md)
60
+ * [Form Field Label & Helper Text Manager](docs/features/form_manager.md)
61
+ * [Netlify Deploy Monitor](docs/features/netlify.md)
60
62
 
61
63
 
62
64
  ### Tutorials
63
65
 
66
+ * [Setting Up GraphQL with Fae](docs/tutorials/graphql_support.md)
64
67
  * [Setting Up Images and Files](docs/tutorials/image_and_files.md)
65
68
  * [Adding Dynamic Relationships to Pages](docs/tutorials/dynamic_relationships_to_pages.md)
66
69
  * [Adding Conditional Validations](docs/tutorials/conditional_validations.md)
@@ -84,6 +87,7 @@ https://www.faecms.com/documentation
84
87
 
85
88
  * [Running Fae Locally](docs/contributing/local_setup.md)
86
89
  * [Fae Standards](docs/contributing/standards.md)
90
+ * [Share Your Creation](docs/contributing/share_your_creation.md)
87
91
 
88
92
  ## [Upgrading](docs/upgrading/index.md)
89
93
 
data/Rakefile CHANGED
@@ -25,9 +25,6 @@ require 'rspec/core/rake_task'
25
25
  desc "Run all specs in spec directory (excluding plugin specs)"
26
26
  RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
27
27
 
28
- # @deprecation - remove require when we drop Rails 4 support
29
- require 'sub_test_task_patch'
30
-
31
28
  require 'rake/testtask'
32
29
  Rake::TestTask.new(:test) do |t|
33
30
  t.libs << 'lib'
@@ -0,0 +1,198 @@
1
+
2
+ /* global Fae, modal, FCH */
3
+
4
+ /**
5
+ * Fae deploy
6
+ * @namespace
7
+ */
8
+
9
+ Fae.deploy = {
10
+
11
+ ready: function() {
12
+ if (!$('body').hasClass('deploy')) return false;
13
+ this.$deployButtons = $('.js-run-deploy');
14
+ this.deployFinished = true;
15
+ this.buttonsEnabled = true;
16
+ this.pollTimeout = null;
17
+ this.pollInterval = 5000;
18
+ this.idleStates = ['ready', 'error']
19
+
20
+ this.pollDeployStatus();
21
+ this.deployButtonListener();
22
+ this.documentFocusListener();
23
+ this.notifyIdle();
24
+ this.refreshDeploysListAndStatuses();
25
+ },
26
+
27
+ deployButtonListener: function() {
28
+ var _this = this;
29
+ _this.$deployButtons.click(function(e) {
30
+ e.preventDefault();
31
+ _this.disableButtons();
32
+ var deploy_hook_type = $(this).data('build-hook-type');
33
+ $.post( '/admin/deploy/deploy_site', { deploy_hook_type: deploy_hook_type }, function(data) {
34
+ // Netlify returns nothing for deploy hook posts
35
+ });
36
+ });
37
+ },
38
+
39
+ documentFocusListener: function() {
40
+ var _this = this;
41
+ document.addEventListener('visibilitychange', function(ev) {
42
+ if (document.visibilityState === 'visible') {
43
+ _this.pollDeployStatus();
44
+ } else if (document.visibilityState === 'hidden') {
45
+ _this.destroyPoll();
46
+ }
47
+ });
48
+ },
49
+
50
+ refreshDeploysListAndStatuses: function() {
51
+ var _this = this;
52
+ $.get('/admin/deploy/deploys_list', function (data) {
53
+ if (data) {
54
+ _this.drawTables(data);
55
+ _this.stateChecks(data);
56
+ }
57
+ });
58
+ },
59
+
60
+ pollDeployStatus: function() {
61
+ var _this = this;
62
+ function poll() {
63
+ _this.refreshDeploysListAndStatuses();
64
+ _this.pollTimeout = setTimeout(poll, _this.pollInterval);
65
+ }
66
+ poll();
67
+ },
68
+
69
+ destroyPoll: function() {
70
+ clearTimeout(this.pollTimeout);
71
+ },
72
+
73
+ notifyRunning: function() {
74
+ $('.deploying-heading').addClass('running');
75
+ $('#js-deploying-section').removeClass('hidden');
76
+ },
77
+
78
+ notifyIdle: function() {
79
+ $('.deploying-heading').removeClass('running');
80
+ $('#js-deploying-section').addClass('hidden');
81
+ },
82
+
83
+ enableButtons: function() {
84
+ var _this = this;
85
+ if (!_this.buttonsEnabled) {
86
+ _this.buttonsEnabled = true;
87
+ _this.$deployButtons.prop('disabled', false);
88
+ }
89
+ },
90
+
91
+ disableButtons: function() {
92
+ var _this = this;
93
+ if (_this.buttonsEnabled) {
94
+ _this.buttonsEnabled = false;
95
+ _this.$deployButtons.prop('disabled', true);
96
+ }
97
+ },
98
+
99
+ afterDeploy: function() {
100
+ var _this = this;
101
+ if (!_this.deployFinished) {
102
+ _this.notifyIdle();
103
+ _this.enableButtons();
104
+ _this.deployFinished = true;
105
+ }
106
+ },
107
+
108
+ drawTables: function(data) {
109
+ var _this = this;
110
+ var runningDeploys = _this.getRunningDeploys(data);
111
+ var pastDeploys = _this.getPastDeploys(data);
112
+ $('.js-deploys-list').find('tbody').find('tr').remove();
113
+ _this.injectTableDeployData(runningDeploys, $('.js-deploys-list.running').find('tbody'));
114
+ _this.injectTableDeployData(pastDeploys, $('.js-deploys-list.past').find('tbody'));
115
+ Fae.navigation.lockFooter();
116
+ },
117
+
118
+ getRunningDeploys: function(data) {
119
+ var _this = this;
120
+ return data.filter(function(deploy) {
121
+ return $.inArray(deploy.state, _this.idleStates) === -1;
122
+ });
123
+ },
124
+
125
+ getPastDeploys: function(data) {
126
+ var _this = this;
127
+ return data.filter(function(deploy) {
128
+ return $.inArray(deploy.state, _this.idleStates) !== -1;
129
+ });
130
+ },
131
+
132
+ injectTableDeployData: function(deploys, $tbody) {
133
+ var _this = this;
134
+ $.each(deploys, function(i, deploy) {
135
+ $tbody.append(
136
+ $('<tr>').append([
137
+ $('<td>').text(deploy.commit_ref !== null ? 'FINE dev update' : deploy.title),
138
+ $('<td>').text(moment(deploy.updated_at).format('MM/DD/YYYY h:mm a')),
139
+ $('<td>').text(_this.deployDuration(deploy)),
140
+ $('<td>').text(_this.deployEnvironment(deploy)),
141
+ $('<td>').html(_this.errorMsg(deploy)),
142
+ ])
143
+ );
144
+ });
145
+ },
146
+
147
+ stateChecks: function(data) {
148
+ var _this = this;
149
+ if (_this.deployIsRunning(data)) {
150
+ _this.notifyRunning();
151
+ _this.disableButtons();
152
+ _this.deployFinished = false;
153
+ } else {
154
+ _this.afterDeploy();
155
+ }
156
+ },
157
+
158
+ valCheck: function(val) {
159
+ if (val !== null) return val;
160
+ },
161
+
162
+ deployIsRunning: function(data) {
163
+ var _this = this;
164
+ var running = false;
165
+ $.each(data, function(i, deploy) {
166
+ if(_this.idleStates.indexOf(deploy.state) === -1) {
167
+ running = true;
168
+ return false;
169
+ }
170
+ });
171
+ return running;
172
+ },
173
+
174
+ deployDuration: function(deploy) {
175
+ if (deploy.deploy_time === null) {
176
+ return '–';
177
+ } else {
178
+ return moment.utc(parseInt(deploy.deploy_time)*1000).format('HH:mm:ss');
179
+ }
180
+ },
181
+
182
+ deployEnvironment: function(deploy) {
183
+ if (deploy.branch === 'master' || deploy.branch === 'main') {
184
+ return 'Production';
185
+ }
186
+ return deploy.branch.charAt(0).toUpperCase() + deploy.branch.slice(1);
187
+ },
188
+
189
+ errorMsg: function(deploy) {
190
+ if (deploy.error_message) {
191
+ var out = 'An error occurred. Please contact your ';
192
+ out += '<a href="/admin/help">FINE team</a>.'
193
+ return out;
194
+ }
195
+ }
196
+
197
+ };
198
+
@@ -6,8 +6,19 @@
6
6
  */
7
7
  Fae.modals = {
8
8
  ready: function() {
9
+ this.$body = $('body');
10
+ this.openClass = 'modal-open';
11
+ this.modalClass = 'MODAL_ID-modal-open';
12
+ this.showEvent = 'modal:show';
13
+ this.shownEvent = 'modal:shown';
14
+ this.closeEvent = 'modal:close';
15
+ this.closedEvent = 'modal:closed';
16
+ this.modalOpen = false;
17
+
9
18
  this.imageModals();
10
19
  this.markdownModalListener();
20
+
21
+ this.ajaxModalListener();
11
22
  },
12
23
 
13
24
  /**
@@ -56,5 +67,88 @@ Fae.modals = {
56
67
  */
57
68
  markdownModalListener: function() {
58
69
  FCH.$document.on('click', '.markdown-support', this.markdownModal);
70
+ },
71
+
72
+ /**
73
+ * load remote data, open modal view
74
+ * @see {@link modals.formModalListener}
75
+ * @has_test {features/form_helpers/fae_input_spec.rb}
76
+ */
77
+ openAjaxModal: function (remoteUrl, relatedTarget) {
78
+ var _this = this;
79
+
80
+ $.get(remoteUrl, function (data) {
81
+ //Open remote url content in modal window
82
+ $(data).modal({
83
+ minHeight: "75%",
84
+ minWidth: "75%",
85
+ overlayClose: true,
86
+ zIndex: 1100,
87
+ containerId: "fae-modal",
88
+ persist: true,
89
+ opacity: 70,
90
+ overlayCss: { backgroundColor: "#000" },
91
+ onOpen: function (dialog) {
92
+ // Fade in modal + show data
93
+ dialog.overlay.fadeIn();
94
+ dialog.container.fadeIn(function() {
95
+ var shownEvent = $.Event(_this.shownEvent, { dialog: dialog, relatedTarget: relatedTarget });
96
+ _this.$body.trigger(shownEvent);
97
+ });
98
+ dialog.data.show();
99
+
100
+ var modalClasses = [_this.createClassFromModalId(relatedTarget.attr('id')), _this.openClass].join(' ');
101
+
102
+ _this.modalOpen = true;
103
+ _this.$body.addClass(modalClasses);
104
+ },
105
+ onShow: function (dialog) {
106
+ var showEvent = $.Event(_this.showEvent, { dialog: dialog, relatedTarget: relatedTarget });
107
+ _this.$body.trigger(showEvent);
108
+
109
+ $(dialog.container).css('height', 'auto')
110
+ },
111
+ onClose: function (dialog) {
112
+ var closeEvent = $.Event(_this.closeEvent, { dialog: dialog, relatedTarget: relatedTarget });
113
+ _this.$body.trigger(closeEvent);
114
+
115
+ // Fade out modal and close
116
+ dialog.container.fadeOut();
117
+ dialog.overlay.fadeOut(function () {
118
+ $.modal.close(); // must call this!
119
+
120
+ var closedEvent = $.Event(_this.closedEvent, { dialog: dialog, relatedTarget: relatedTarget });
121
+ var modalClasses = [_this.createClassFromModalId(relatedTarget.attr('id')), _this.openClass].join(' ');
122
+
123
+ _this.modalOpen = false;
124
+ _this.$body.removeClass(modalClasses);
125
+ _this.$body.trigger(closedEvent);
126
+ });
127
+ }
128
+ });
129
+
130
+ });
131
+ },
132
+
133
+ /**
134
+ * Click event listener for ajax modal links triggering specific view within modal popup
135
+ * @fires {@link modals.ajaxModal}
136
+ * @has_test {features/form_helpers/fae_input_spec.rb}
137
+ */
138
+ ajaxModalListener: function () {
139
+ var _this = this;
140
+
141
+ FCH.$document.on('click', '.js-fae-modal', function (e) {
142
+ e.preventDefault();
143
+ var $this = $(this);
144
+ var url = $this.attr('href');
145
+ var id = $this.attr('id');
146
+
147
+ _this.openAjaxModal(url, $this)
148
+ });
149
+ },
150
+
151
+ createClassFromModalId: function(modalId) {
152
+ return this.modalClass.replace('MODAL_ID', modalId);
59
153
  }
60
154
  };
@@ -17,16 +17,14 @@ Fae.tables = {
17
17
  sort_cookie_name: 'Fae_table_sort_preferences',
18
18
 
19
19
  ready: function() {
20
- // @depreciation - remove `|| FCH.exists('.main_table-sort_columns')` and only use FCH.exists('.js-sort-column') in v2.0
21
- if (FCH.exists('.js-sort-column') || FCH.exists('.main_table-sort_columns')) {
20
+ if (FCH.exists('.js-sort-column')) {
22
21
  this.dateColumnSorting();
23
22
  this.columnSorting();
24
23
  this.defaultSortCookie();
25
24
  this.sortColumnsFromCookies();
26
25
  }
27
26
 
28
- // @depreciation - remove || FCH.exists('.main_content-sortable-handle') and only use FCH.exists('.sortable-handle') in v2.0
29
- if (FCH.exists('.sortable-handle') || FCH.exists('.main_content-sortable-handle')) {
27
+ if (FCH.exists('.sortable-handle')) {
30
28
  this.rowSorting();
31
29
  }
32
30
 
@@ -36,10 +34,7 @@ Fae.tables = {
36
34
  this.collapsibleTable();
37
35
  }
38
36
 
39
- // @depreciation - remove conditional wrapping and call endingSelectShim like `this.endingSelectShim()` in v2.0
40
- if (FCH.exists('form ' + Fae.content_selector)) {
41
- this.endingSelectShim(Fae.content_selector);
42
- }
37
+ this.endingSelectShim();
43
38
 
44
39
  if (FCH.exists('.js-tooltip')) {
45
40
  this.tooltip();
@@ -54,8 +49,7 @@ Fae.tables = {
54
49
  var path = window.location.pathname;
55
50
  var cookie_value = Cookies.getJSON(_this.sort_cookie_name);
56
51
 
57
- // @depreciation - remove `, .main_table-sort_columns` and only use '.js-sort-column' in v2.0
58
- $('.js-sort-column, .main_table-sort_columns')
52
+ $('.js-sort-column')
59
53
  .tablesorter()
60
54
  .on('sortEnd', function(e) {
61
55
  var $this = $(this);
@@ -142,8 +136,7 @@ Fae.tables = {
142
136
  return;
143
137
  }
144
138
 
145
- // @depreciation - remove `, .main_table-sort_columns` and only use '.js-sort-column' in v2.0
146
- $('.js-sort-column, .main_table-sort_columns').each(function(idx) {
139
+ $('.js-sort-column').each(function(idx) {
147
140
  // If this table exists in the cookie hash
148
141
  if (cookie_value[path].hasOwnProperty(idx)) {
149
142
  // Use array value within another array because of how tablesorter accepts this argument
@@ -156,15 +149,10 @@ Fae.tables = {
156
149
  * Make table rows draggable by user
157
150
  */
158
151
  rowSorting: function() {
159
- // @depreciation - remove sort_selector var in v2.0
160
- var sort_selector = FCH.exists('.sortable-handle') ? '.sortable-handle' : '.main_content-sortable-handle';
161
-
162
- // @depreciation - remove `, .main_content-sortable` and only use '.js-sort-row' in v2.0
163
- $('.js-sort-row, .main_content-sortable').sortable({
152
+ $('.js-sort-row').sortable({
164
153
  items: 'tbody tr',
165
154
  opacity: 0.8,
166
- // @depreciation - replace sort_selector with '.sortable-handle' in v2.0
167
- handle: (sort_selector),
155
+ handle: ('.sortable-handle'),
168
156
 
169
157
  //helper function to preserve the width of the table row
170
158
  helper: function(e, $tr) {
@@ -271,11 +259,9 @@ Fae.tables = {
271
259
 
272
260
  /**
273
261
  * Add extra space if the last item in a form is a select menu so the dropdown doesn't run off the screen or section
274
- * @param {String} selector - Last of type element to target
275
- * @deprecation remove selector arg and replace selector variable with '.content' in v2.0
276
262
  */
277
- endingSelectShim: function(selector) {
278
- $('form ' + selector + ':last-of-type').each(function() {
263
+ endingSelectShim: function() {
264
+ $('form .content:last-of-type').each(function() {
279
265
  var $last_item = $(this).find('.input:last-of-type');
280
266
 
281
267
  if( $last_item.hasClass('select') ) {
@@ -342,8 +328,8 @@ Fae.tables = {
342
328
  */
343
329
  sizeFixedHeader: function() {
344
330
  var $tables = $('.content table');
345
- // @depreciation - change value from ternary to $('.js-content-header').outerHeight() in v2.0
346
- var header_height = FCH.exists('.js-content-header') ? $('.js-content-header').outerHeight() : $('.main_content-header').outerHeight();
331
+
332
+ var header_height = $('.js-content-header').outerHeight();
347
333
  if(FCH.large_down) {
348
334
  header_height = $('#js-main-header').outerHeight();
349
335
  }
@@ -13,8 +13,8 @@
13
13
  //= require jquery
14
14
  //= require jquery_ujs
15
15
  //= require jquery.remotipart
16
- //= require jquery.ui.sortable
17
- //= require jquery.ui.datepicker
16
+ //= require jquery-ui/widgets/sortable
17
+ //= require jquery-ui/widgets/datepicker
18
18
  //= require underscore
19
19
  //= require json2
20
20
  //= require judge
@@ -46,6 +46,7 @@
46
46
  //= require fae/form/_cancel
47
47
  //= require fae/form/_ajax
48
48
  //= require fae/form/_filtering
49
+ //= require fae/form/_form_manager
49
50
  //= require fae/form/fae_chosen
50
51
  //= require fae/form/fileinputer
51
52
 
@@ -57,6 +58,7 @@
57
58
 
58
59
  //= require fae/_modals
59
60
  //= require fae/_tables
61
+ //= require fae/_deploy
60
62
 
61
63
  //= require fae
62
64
 
@@ -5,8 +5,4 @@
5
5
  window.FCH = new FrobCoreHelpers(Fae, {
6
6
  mobile_fps: false
7
7
  });
8
-
9
- // Selector to support pre-1.3 changes
10
- // @depreciation - replace Fae.content_selector property and all instances of it with '.content' in v2.0
11
- Fae.content_selector = FCH.exists('.main_content-section') || FCH.exists('.main_content-sections') ? '.main_content-section-area' : '.content';
12
8
  })();
@@ -66,6 +66,11 @@ Fae.form.ajax = {
66
66
  $wrapper.find('.input.file').fileinputer();
67
67
  }
68
68
 
69
+ this.$nested_form = $('.nested-form');
70
+
71
+ // Bind validation to nested form fields added by AJAX
72
+ Fae.form.validator.bindValidationEvents(this.$nested_form);
73
+
69
74
  // Reinitialize form elements
70
75
  Fae.form.dates.initDatepicker();
71
76
  Fae.form.dates.initDateRangePicker();
@@ -73,7 +78,13 @@ Fae.form.ajax = {
73
78
  Fae.form.slugger.addListener();
74
79
  Fae.form.validator.length_counter.init();
75
80
  Fae.form.text.initMarkdown();
81
+ Fae.form.text.initHTML();
76
82
  Fae.form.checkbox.setCheckboxAsActive();
83
+ Fae.form.select.init();
84
+ Fae.form.formManager.setupAllFields($wrapper.find('form'));
85
+
86
+ // validate nested form fields on submit
87
+ Fae.form.validator.formValidate(this.$nested_form);
77
88
 
78
89
  $wrapper.find('.hint').hinter();
79
90
  });
@@ -123,13 +134,10 @@ Fae.form.ajax = {
123
134
  if($html.hasClass('js-addedit-form') || $html.hasClass( 'js-index-addedit-form' )) {
124
135
  // we're returning the table, replace everything
125
136
  _this._addEditReplaceAndReinit($this, $html.html(), $target);
126
- } else if ($html.hasClass('nested-form') || $html.hasClass('form_content-wrapper')) {
127
-
128
- // @depreciation - remove `|| $html.hasClass('form_content_wrapper')` from above conditional as well as the following ternary (value should just be '.nested-form') in v2.0
129
- var form_wrapper_selector = $html.hasClass('nested-form') ? '.nested-form' : '.form_content-wrapper';
137
+ } else if ($html.hasClass('nested-form')) {
130
138
 
131
139
  // we're returning the form due to an error, just replace the form
132
- $this.find( form_wrapper_selector ).replaceWith(data);
140
+ $this.find('.nested-form' ).replaceWith($html);
133
141
  $this.find('.select select').fae_chosen();
134
142
  $this.find('.input.file').fileinputer();
135
143
 
@@ -139,6 +147,7 @@ Fae.form.ajax = {
139
147
  Fae.form.validator.length_counter.init();
140
148
  Fae.form.checkbox.setCheckboxAsActive();
141
149
  Fae.form.text.initMarkdown();
150
+ Fae.form.text.initHTML();
142
151
 
143
152
  FCH.smoothScroll($this.find('.js-addedit-form-wrapper'), 500, 100, 120);
144
153
  }
@@ -286,11 +295,21 @@ Fae.form.ajax = {
286
295
  },
287
296
 
288
297
  /**
289
- * Attaching click handlers to #main_content to allow ajax replacement
298
+ * Attaching click handlers to #js-main-content to allow ajax replacement
290
299
  * @todo Clean this up, moving listeners into their respective component classes (select, checkbox, etc.)
291
300
  */
292
301
  htmlListeners: function() {
293
- $('#js-main-content, .login-form > form')
302
+ $('#js-main-content, .login-form > form, #simplemodal-data')
303
+
304
+ /**
305
+ * For the delete button on file input
306
+ */
307
+ .on('click', '.js-file-clear', function(e) {
308
+ e.preventDefault();
309
+ var $parent = $(this).parent();
310
+ $parent.next().show();
311
+ $parent.hide();
312
+ })
294
313
 
295
314
  /**
296
315
  * For the yes/no slider
@@ -35,4 +35,5 @@ Fae.form.cancel = {
35
35
 
36
36
  $('form').on('change', 'input, textarea, select', updateCancel);
37
37
  }
38
+
38
39
  };
@@ -25,6 +25,7 @@ Fae.form.filtering = {
25
25
  }
26
26
 
27
27
  this.setFilterDropDowns();
28
+ this.setTextInputs();
28
29
  this.filterFormListeners();
29
30
  this.paginationListeners();
30
31
  this.sortingSetup();
@@ -87,6 +88,7 @@ Fae.form.filtering = {
87
88
  // update search param when form submits
88
89
  .on('submit', function(ev) {
89
90
  $('.js-reset-btn').show();
91
+ $('.js-reset-btn').removeClass('hidden');
90
92
  _this.updateFryrAndResetPaging('search', $('#filter_search').val());
91
93
  return false;
92
94
  })
@@ -117,6 +119,17 @@ Fae.form.filtering = {
117
119
  _this.updateFryrAndResetPaging(key, value);
118
120
 
119
121
  $('.js-reset-btn').show();
122
+ $('.js-reset-btn').removeClass('hidden');
123
+ })
124
+
125
+ // update hash when date inputs changed
126
+ .on('change', '.datepicker input', function() {
127
+ var key = $(this).attr('id').split('filter_')[1];
128
+ var value = $(this).val();
129
+ timer = setTimeout(function() {
130
+ _this.updateFryrAndResetPaging(key, value);
131
+ $('.js-reset-btn').show();
132
+ }, 500);
120
133
  });
121
134
  },
122
135
 
@@ -147,6 +160,27 @@ Fae.form.filtering = {
147
160
  $('.js-reset-btn').show();
148
161
  },
149
162
 
163
+ /**
164
+ * Sets filter dropdowns on page load based on Fryr params
165
+ */
166
+ setTextInputs: function() {
167
+ // Exit early if this.fry.params is blank
168
+ if ($.isEmptyObject(this.fry.params)) {
169
+ return;
170
+ }
171
+
172
+ // Loop through all available this.fry.params to find the select menu and the proper option
173
+ $.each(this.fry.params, function(key, value) {
174
+ var $input = $('.js-filter-form .table-filter-group.text-input #filter_' + key);
175
+
176
+ if($input.length) {
177
+ $input.val(decodeURIComponent(value));
178
+ }
179
+ });
180
+
181
+ $('.js-reset-btn').show();
182
+ },
183
+
150
184
  /**
151
185
  * Updates a Fryr param while reseting paging
152
186
  * Use for most cases of pushing a single params to Fryr, as paging will always reset in those cases
@@ -20,6 +20,7 @@ Fae.form = {
20
20
  this.ajax.init();
21
21
  this.filtering.init();
22
22
  this.slugger.init();
23
+ this.formManager.init();
23
24
 
24
25
  // input type=file customization
25
26
  // This doesn't work in IE. It's not worth figuring out why by this point. IE9 gets plain file uploader.