beyond_canvas 0.19.2.pre → 0.23.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -45
  3. data/app/assets/images/icons/adblocker.svg +5 -0
  4. data/app/assets/images/icons/checkbox_checked.svg +1 -1
  5. data/app/assets/images/icons/checkbox_unchecked.svg +1 -1
  6. data/app/assets/images/icons/external_link.svg +1 -0
  7. data/app/assets/images/icons/toggle.svg +1 -0
  8. data/app/assets/images/icons/toggle_checked.svg +3 -0
  9. data/app/assets/images/icons/toggle_unchecked.svg +3 -0
  10. data/app/assets/javascripts/beyond_canvas/base.js +107 -44
  11. data/app/assets/stylesheets/beyond_canvas/base.scss +21 -18
  12. data/app/assets/stylesheets/beyond_canvas/components/_action_bar.scss +11 -6
  13. data/app/assets/stylesheets/beyond_canvas/components/_breadcrumbs.scss +8 -4
  14. data/app/assets/stylesheets/beyond_canvas/components/_buttons.scss +50 -56
  15. data/app/assets/stylesheets/beyond_canvas/components/_cards.scss +20 -12
  16. data/app/assets/stylesheets/beyond_canvas/components/_collapse.scss +33 -0
  17. data/app/assets/stylesheets/beyond_canvas/components/_flash.scss +13 -12
  18. data/app/assets/stylesheets/beyond_canvas/components/_forms.scss +2 -2
  19. data/app/assets/stylesheets/beyond_canvas/components/_inputs.scss +186 -38
  20. data/app/assets/stylesheets/beyond_canvas/components/_links.scss +80 -4
  21. data/app/assets/stylesheets/beyond_canvas/components/_main.scss +3 -3
  22. data/app/assets/stylesheets/beyond_canvas/components/_menu.scss +13 -0
  23. data/app/assets/stylesheets/beyond_canvas/components/_modals.scss +48 -18
  24. data/app/assets/stylesheets/beyond_canvas/components/_notices.scss +12 -13
  25. data/app/assets/stylesheets/beyond_canvas/components/_scrollbox.scss +5 -4
  26. data/app/assets/stylesheets/beyond_canvas/components/_select2.scss +70 -0
  27. data/app/assets/stylesheets/beyond_canvas/components/_statuses.scss +28 -0
  28. data/app/assets/stylesheets/beyond_canvas/components/_step_list.scss +67 -0
  29. data/app/assets/stylesheets/beyond_canvas/components/_tables.scss +10 -5
  30. data/app/assets/stylesheets/beyond_canvas/components/_titles.scss +1 -1
  31. data/app/assets/stylesheets/beyond_canvas/mailer.scss +2 -1
  32. data/app/assets/stylesheets/beyond_canvas/settings/_base_variables.scss +241 -0
  33. data/app/assets/stylesheets/beyond_canvas/settings/{_variables.scss → _constant_variables.scss} +60 -53
  34. data/app/assets/stylesheets/beyond_canvas/settings/_custom_variables.scss +233 -0
  35. data/app/assets/stylesheets/beyond_canvas/settings/_typography.scss +7 -3
  36. data/app/assets/stylesheets/beyond_canvas/utilities/_mixins.scss +39 -3
  37. data/app/controllers/beyond_canvas/authentications_controller.rb +18 -2
  38. data/app/controllers/beyond_canvas/system_controller.rb +3 -1
  39. data/app/controllers/beyond_canvas/webhooks_controller.rb +49 -0
  40. data/app/controllers/concerns/beyond_canvas/add_blocker_check.rb +17 -0
  41. data/app/controllers/concerns/beyond_canvas/custom_styles.rb +54 -0
  42. data/app/controllers/concerns/beyond_canvas/locale_management.rb +31 -8
  43. data/app/controllers/concerns/beyond_canvas/request_validation.rb +6 -0
  44. data/app/form_builders/beyond_canvas/form_builder.rb +62 -49
  45. data/app/helpers/beyond_canvas/application_helper.rb +48 -4
  46. data/app/helpers/beyond_canvas/form_tag_helper.rb +130 -0
  47. data/app/helpers/beyond_canvas/statuses_helper.rb +26 -0
  48. data/app/javascript/beyond_canvas/base.js +1 -1
  49. data/app/javascript/beyond_canvas/initializers/buttons.js +49 -29
  50. data/app/javascript/beyond_canvas/initializers/collapse.js +8 -0
  51. data/app/javascript/beyond_canvas/initializers/flash.js +33 -11
  52. data/app/javascript/beyond_canvas/initializers/inputs.js +9 -4
  53. data/app/javascript/beyond_canvas/initializers/modals.js +46 -10
  54. data/app/views/beyond_canvas/mailer/_header.html.erb +2 -2
  55. data/app/views/beyond_canvas/shared/_breadcrumbs.html.erb +5 -2
  56. data/app/views/beyond_canvas/shared/_flash.html.erb +14 -10
  57. data/app/views/beyond_canvas/shared/_head.html.erb +4 -0
  58. data/app/views/beyond_canvas/shared/_locales.html.erb +1 -1
  59. data/app/views/layouts/beyond_canvas/application.html.erb +1 -2
  60. data/app/views/layouts/beyond_canvas/public.html.erb +1 -1
  61. data/config/initializers/beyond_canvas/constants.rb +13 -0
  62. data/config/initializers/beyond_canvas/session_store.rb +8 -0
  63. data/lib/beyond_canvas/configuration.rb +9 -1
  64. data/lib/beyond_canvas/engine.rb +7 -0
  65. data/lib/beyond_canvas/rails/routes.rb +27 -7
  66. data/lib/beyond_canvas/version.rb +1 -1
  67. data/lib/beyond_canvas/webhook_event_registration.rb +19 -0
  68. data/lib/beyond_canvas.rb +6 -4
  69. data/lib/generators/beyond_canvas/custom_styles/templates/beyond_canvas_custom_styles.scss +33 -0
  70. data/lib/generators/beyond_canvas/install/install_generator.rb +6 -0
  71. data/lib/generators/beyond_canvas/install/templates/beyond_canvas.rb.erb +38 -1
  72. data/lib/generators/beyond_canvas/model/model_generator.rb +3 -0
  73. data/lib/generators/beyond_canvas/webhook/templates/webhooks_controller.rb +22 -0
  74. data/lib/generators/beyond_canvas/webhook/webhook_generator.rb +15 -0
  75. data/lib/models/concerns/authentication.rb +10 -3
  76. data/lib/models/concerns/utils.rb +6 -5
  77. data/lib/models/concerns/webhook.rb +123 -0
  78. data/lib/models/shop.rb +1 -0
  79. metadata +73 -40
  80. data/app/assets/stylesheets/beyond_canvas/components/_comments.scss +0 -6
  81. data/app/assets/stylesheets/beyond_canvas/components/_containers.scss +0 -37
  82. data/app/views/beyond_canvas/shared/_modal.html.erb +0 -6
  83. data/config/routes.rb +0 -12
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BeyondCanvas
4
+ module StatusesHelper # :nodoc:
5
+ %i[good warning danger neutral].each do |method|
6
+ define_method :"status_#{method}" do |name = nil, html_options = nil, &block|
7
+ status_render(method, name, html_options, &block)
8
+ end
9
+ end
10
+
11
+ private
12
+
13
+ def status_render(method, name = nil, html_options = nil, &block)
14
+ if block_given?
15
+ html_options = name
16
+ name = block
17
+ end
18
+
19
+ html_options ||= {}
20
+
21
+ html_options.merge!(class: "status status--#{method}") { |_key, old_val, new_val| [new_val, old_val].join(' ') }
22
+
23
+ content_tag('span', block_given? ? capture(&name) : name, html_options)
24
+ end
25
+ end
26
+ end
@@ -1,6 +1,6 @@
1
1
  import 'jquery';
2
-
3
2
  import './initializers/buttons';
3
+ import './initializers/collapse';
4
4
  import './initializers/flash';
5
5
  import './initializers/inputs';
6
6
  import './initializers/modals';
@@ -2,7 +2,7 @@ const SPINNER_ANIMATION_TIMEOUT = 125;
2
2
  const BUTTON_SELECTORS = '[class^="button"]';
3
3
 
4
4
  (function ($) {
5
- const onDOMReady = function (e) {
5
+ const onDOMReady = function () {
6
6
  const inputs = $('input, textarea, select').not(
7
7
  ':input[type=button], :input[type=submit], :input[type=reset]'
8
8
  );
@@ -19,48 +19,36 @@ const BUTTON_SELECTORS = '[class^="button"]';
19
19
  });
20
20
 
21
21
  $(BUTTON_SELECTORS).each(function () {
22
- var button = $(this);
23
-
24
- // Add width attribute and save old width
25
- button.width(button.width());
26
- button.data('oldWidth', button.width());
27
-
28
- // Add the spinner
29
- if (button.find('.spinner').length == 0) {
30
- button.prepend(`
31
- <div class="spinner">
32
- <div class="bounce1"></div>
33
- <div class="bounce2"></div>
34
- <div class="bounce3"></div>
35
- </div>`);
36
- }
37
-
38
- // Bind ajax:success and ajax:error to the form the button belongs to
39
- button
40
- .closest('form')
41
- .on('ajax:success', function () {
42
- $.restoreActionElements();
43
- })
44
- .on('ajax:error', function () {
45
- $.restoreActionElements();
46
- });
22
+ $(this).buildButton();
47
23
  });
48
24
  };
49
25
 
50
- $(document).on('confirm:complete', function () {
26
+ $(document).on('confirm:complete', function () {
51
27
  $.restoreActionElements();
52
28
  });
53
29
 
54
- $(document).on('click', BUTTON_SELECTORS, function () {
30
+ $(document).on('click', BUTTON_SELECTORS, function (e) {
31
+ var button = $(this);
32
+
33
+ if(e.target.attributes.getNamedItem('target')?.value === '_blank') return;
34
+
55
35
  $.disableActionElements();
56
- $(this).showSpinner();
36
+
37
+ if (!button.hasClass('button--no-spinner')) {
38
+ $(this).showSpinner();
39
+ }
57
40
  });
58
41
 
59
42
  $(document).on('ready page:load turbolinks:load', onDOMReady);
43
+
44
+ $(document).on('beforeunload turbolinks:before-visit', function () {
45
+ $.restoreActionElements();
46
+ });
60
47
  })(jQuery);
61
48
 
62
49
  $.extend({
63
50
  restoreActionElements: function () {
51
+ setTimeout(function () {
64
52
  // Hide spinners
65
53
  $(BUTTON_SELECTORS).each(function (_, button) {
66
54
  setTimeout(function () {
@@ -75,6 +63,7 @@ $.extend({
75
63
  $('a, input[type="submit"], input[type="button"], input[type="reset"], button').each(function () {
76
64
  $(this).removeClass('actions--disabled');
77
65
  });
66
+ }, 100);
78
67
  },
79
68
  disableActionElements: function () {
80
69
  $('a, input[type="submit"], input[type="button"], input[type="reset"], button').each(function () {
@@ -84,6 +73,37 @@ $.extend({
84
73
  });
85
74
 
86
75
  $.fn.extend({
76
+ buildButton: function() {
77
+ var button = $(this);
78
+
79
+ if (button.is('[class^=button]')) {
80
+ if (!button.hasClass('button--no-spinner')) {
81
+ // Add width attribute and save old width
82
+ button.width(button.width());
83
+ button.data('oldWidth', button.width());
84
+
85
+ // Add the spinner
86
+ if (button.find('.spinner').length == 0) {
87
+ button.prepend(`
88
+ <div class="spinner">
89
+ <div class="bounce1"></div>
90
+ <div class="bounce2"></div>
91
+ <div class="bounce3"></div>
92
+ </div>`);
93
+ }
94
+ }
95
+
96
+ // Bind ajax:success and ajax:error to the form the button belongs to
97
+ button
98
+ .closest('form')
99
+ .on('ajax:success', function () {
100
+ $.restoreActionElements();
101
+ })
102
+ .on('ajax:error', function () {
103
+ $.restoreActionElements();
104
+ });
105
+ }
106
+ },
87
107
  showSpinner: function () {
88
108
  var button = $(this);
89
109
 
@@ -0,0 +1,8 @@
1
+ (function ($) {
2
+ $(document).on('click', "[data-toggle='collapse']", function (e) {
3
+ e.preventDefault();
4
+
5
+ $($(this).attr('data-target')).slideToggle();
6
+ $(this).find('.collapse__icon').toggleClass('collapse__icon--open');
7
+ });
8
+ })(jQuery);
@@ -9,18 +9,40 @@
9
9
  }, 100);
10
10
  };
11
11
 
12
- $(document).on('click', '.flash', function () {
13
- closeAlert();
12
+ $(document).on('click', '.flash__close', function () {
13
+ $.closeAlert();
14
14
  });
15
15
 
16
- $(document).on('ready page:load turbolinks:load', onDOMReady);
16
+ $(document).on('ready page:load turbolinks:load bc.flash.shown', onDOMReady);
17
17
  })(jQuery);
18
18
 
19
- function closeAlert() {
20
- $('.flash')
21
- .removeClass('flash--shown')
22
- .delay(700)
23
- .queue(function () {
24
- $(this).remove();
25
- });
26
- }
19
+ $.extend({
20
+ showFlash: function(status, message) {
21
+ const flash = `
22
+ <div class="flash">
23
+ <div class="flash__icon flash__icon--${status}">
24
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm6 16.538l-4.592-4.548 4.546-4.587-1.416-1.403-4.545 4.589-4.588-4.543-1.405 1.405 4.593 4.552-4.547 4.592 1.405 1.405 4.555-4.596 4.591 4.55 1.403-1.416z"></path></svg>
25
+ </div>
26
+ <div class="flash__message">
27
+ ${message}
28
+ </div>
29
+ <div class="flash__close">
30
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M24 20.188l-8.315-8.209 8.2-8.282-3.697-3.697-8.212 8.318-8.31-8.203-3.666 3.666 8.321 8.24-8.206 8.313 3.666 3.666 8.237-8.318 8.285 8.203z"></path></svg>
31
+ </div>
32
+ </div>`;
33
+
34
+ $(document).trigger('bc.flash.show');
35
+ $('#flash').html(flash);
36
+ $(document).trigger('bc.flash.shown');
37
+ },
38
+ closeAlert: function() {
39
+ $(document).trigger('bc.flash.hide');
40
+ $('.flash')
41
+ .removeClass('flash--shown')
42
+ .delay(700)
43
+ .queue(function () {
44
+ $(this).remove();
45
+ });
46
+ $(document).trigger('bc.flash.hidden');
47
+ }
48
+ });
@@ -1,15 +1,15 @@
1
1
  (function ($) {
2
2
  const onDOMReady = function () {
3
3
  $('input[type="file"]').each(function () {
4
- var $input = $(this),
4
+ const $input = $(this),
5
5
  $label = $(`.input__file__text.${$input.attr('id')}`),
6
6
  labelVal = $label.html();
7
7
 
8
8
  $input.on('change', function (e) {
9
- var fileName = '';
9
+ let fileName = '';
10
10
 
11
11
  if (this.files && this.files.length > 1)
12
- fileName = (this.getAttribute('data-multiple-caption') || '').replace(
12
+ fileName = (this.getAttribute('data-multiple-caption') || '{count} files selected').replace(
13
13
  '{count}',
14
14
  this.files.length
15
15
  );
@@ -33,5 +33,10 @@
33
33
  });
34
34
  };
35
35
 
36
- $(document).on('ready page:load turbolinks:load', onDOMReady);
36
+ $(document).on('ready page:load turbolinks:load', () => {
37
+ const observer = new MutationObserver(() => onDOMReady());
38
+
39
+ onDOMReady();
40
+ observer.observe(document.body, { childList: true, subtree: true });
41
+ });
37
42
  })(jQuery);
@@ -1,14 +1,50 @@
1
- $.extend({
2
- displayModal: function (content, options = {}) {
3
- $('#modal').find('#modal__content').html(content);
4
- $('#modal').css('display', 'flex');
1
+ (function ($) {
2
+ const onDOMReady = function () {
3
+ $('.modal').each(function () {
4
+ $(this).hide().css('visibility', 'visible');
5
+ });
6
+ };
7
+
8
+ $(document).on('click', '[data-toggle="modal"]', function (e) {
9
+ e.preventDefault();
10
+
11
+ const dataTarget = $(this).attr('data-target');
12
+
5
13
  $.restoreActionElements();
6
- $(document).trigger('modal:opened', options['extraEventParameters']);
14
+ $(dataTarget).showModal();
15
+ });
16
+
17
+ $(document).on('click', '[data-dismiss="modal"]', function (e) {
18
+ e.preventDefault();
19
+
20
+ const dataTarget = $(this).closest('.modal');
21
+
22
+ $.restoreActionElements();
23
+ $(dataTarget).hideModal();
24
+ });
25
+
26
+ $(document).on('ready page:load turbolinks:load', onDOMReady);
27
+ })(jQuery);
28
+
29
+ $.fn.extend({
30
+ showModal: function () {
31
+ const modal = $(this);
32
+
33
+ modal.trigger('bc.modal.show');
34
+
35
+ $.restoreActionElements();
36
+ modal.css('display', 'flex');
37
+
38
+ modal.trigger('bc.modal.shown');
7
39
  },
8
- closeModal: function () {
9
- $('#modal').find('#modal__content').empty();
10
- $('#modal').css('display', 'none');
40
+ hideModal: function () {
41
+ const modal = $(this);
42
+
43
+ modal.trigger('bc.modal.hide');
44
+
11
45
  $.restoreActionElements();
12
- $(document).trigger('modal:closed');
13
- }
46
+ modal.hide();
47
+
48
+ modal.trigger('bc.modal.hidden');
49
+ },
14
50
  });
@@ -1,8 +1,8 @@
1
1
  <!-- Email Header : BEGIN -->
2
2
  <tr>
3
3
  <td style="padding: 20px 0; text-align: center">
4
- <% if BeyondCanvas.configuration.site_logo.present? %>
5
- <%= image_tag BeyondCanvas.configuration.site_logo, width: "200", height: "50", alt: "alt_text", border: "0", style: "height: auto; font-family: sans-serif; font-size: 15px; line-height: 15px; color: #555555;" %>
4
+ <% if BeyondCanvas.configuration.email_logo.present? %>
5
+ <%= image_tag BeyondCanvas.configuration.email_logo, width: "200", height: "50", border: "0", style: "height: auto; font-family: sans-serif; font-size: 15px; line-height: 15px; color: #555555;" %>
6
6
  <% end %>
7
7
  </td>
8
8
  </tr>
@@ -1,12 +1,15 @@
1
- <% if is_cockpit_app? %>
1
+ <% if is_cockpit_app? && breadcrumb_trail.count.positive? %>
2
2
 
3
3
  <div class='breadcrumbs'>
4
4
 
5
5
  <%= inline_svg_tag 'icons/home.svg' %>
6
6
 
7
+ <% i = 1 %>
8
+
7
9
  <% breadcrumb_trail do |crumb| %>
8
10
  <%= link_to crumb.name, crumb.url, class: "breadcrumb__item#{ '--current' if crumb.current? }" %>
9
- <% unless crumb.current? %><%= inline_svg_tag 'icons/arrow_right.svg' %><% end %>
11
+ <% unless i == breadcrumb_trail.count || crumb.current? %><%= inline_svg_tag 'icons/arrow_right.svg' %><% end %>
12
+ <% i += 1 %>
10
13
  <% end %>
11
14
 
12
15
  </div>
@@ -2,21 +2,25 @@
2
2
 
3
3
  <% flash.each do |key, value| %>
4
4
 
5
- <div class="flash">
5
+ <% unless value.blank? %>
6
6
 
7
- <div class="flash__icon flash__icon--<%= key %>">
8
- <%= get_flash_icon(key) %>
9
- </div>
7
+ <div class="flash">
10
8
 
11
- <div class="flash__message">
12
- <%= value %>
13
- </div>
9
+ <div class="flash__icon flash__icon--<%= key %>">
10
+ <%= get_flash_icon(key) %>
11
+ </div>
12
+
13
+ <div class="flash__message">
14
+ <%= value %>
15
+ </div>
16
+
17
+ <div class="flash__close">
18
+ <%= inline_svg_tag 'icons/flash_close.svg' %>
19
+ </div>
14
20
 
15
- <div class="flash__close">
16
- <%= inline_svg_tag 'icons/flash_close.svg' %>
17
21
  </div>
18
22
 
19
- </div>
23
+ <% end %>
20
24
 
21
25
  <% end %>
22
26
 
@@ -16,6 +16,10 @@
16
16
  <% end %>
17
17
  <% end %>
18
18
 
19
+ <% if BeyondCanvas.configuration.cockpit_app %>
20
+ <%= stylesheet_link_tag cookies[:custom_styles_url] %>
21
+ <% end %>
22
+
19
23
  <% BeyondCanvas.configuration.javascripts.each do |path| %>
20
24
  <% if BeyondCanvas.configuration.skip_webpacker %>
21
25
  <%= javascript_include_tag path %>
@@ -1,5 +1,5 @@
1
1
  <% if show_locale_switch? && !is_cockpit_app? %>
2
- <%= form_for :system, url: beyond_canvas.update_locale_path, method: :put do |f| %>
2
+ <%= form_for :system, url: update_locale_path, method: :put do |f| %>
3
3
  <%= f.select :locale, I18n.available_locales.collect { |l| [translate_locale(l), l] },
4
4
  { selected: cookies[:locale] },
5
5
  class: 'select--locale',
@@ -3,7 +3,7 @@
3
3
  <html>
4
4
  <%= render 'beyond_canvas/shared/head' %>
5
5
 
6
- <body class="body--application"<% if is_cockpit_app? && Rails.env.development? %> style="display: flex;"<% end %>>
6
+ <body class="beyond-canvas body--application"<% if is_cockpit_app? && Rails.env.development? %> style="display: flex;"<% end %>>
7
7
 
8
8
  <%= render 'beyond_canvas/shared/sidebar' %>
9
9
 
@@ -11,7 +11,6 @@
11
11
 
12
12
  <%= render 'beyond_canvas/shared/flash' %>
13
13
  <%= render 'beyond_canvas/shared/locales' %>
14
- <%= render 'beyond_canvas/shared/modal' %>
15
14
  <%= render 'beyond_canvas/shared/menu' %>
16
15
  <%= render 'beyond_canvas/shared/action_bar' %>
17
16
 
@@ -3,7 +3,7 @@
3
3
  <html>
4
4
  <%= render 'beyond_canvas/shared/head' %>
5
5
 
6
- <body class="body--public">
6
+ <body class="beyond-canvas body--public">
7
7
 
8
8
  <main class="main <%= params[:controller].gsub(/[\/_]/, "-") %>--<%= params[:action] %>">
9
9
 
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ if BeyondCanvas.configuration.cockpit_app == true && !Rails.env.development?
4
+ COOKIES_ATTRIBUTES = {
5
+ expires: 1.year.from_now,
6
+ same_site: :none,
7
+ secure: true
8
+ }.freeze
9
+ else
10
+ COOKIES_ATTRIBUTES = {
11
+ expires: 1.year.from_now
12
+ }.freeze
13
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ if BeyondCanvas.configuration.cockpit_app == true && !Rails.env.development?
4
+ Rails.application.config.session_store :cookie_store, {
5
+ secure: true,
6
+ same_site: :none
7
+ }
8
+ end