trestle 0.8.9 → 0.8.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/trestle/components/_confirmation.js +31 -14
  3. data/app/assets/javascripts/trestle/components/_form.js +19 -15
  4. data/app/assets/javascripts/trestle/components/_tabs.js +1 -1
  5. data/app/assets/stylesheets/trestle/components/_breadcrumbs.scss +12 -0
  6. data/app/assets/stylesheets/trestle/components/_buttons.scss +102 -1
  7. data/app/assets/stylesheets/trestle/components/_content.scss +41 -21
  8. data/app/assets/stylesheets/trestle/components/_input-group.scss +8 -1
  9. data/app/assets/stylesheets/trestle/components/_modal.scss +3 -0
  10. data/app/assets/stylesheets/trestle/components/_pagination.scss +0 -3
  11. data/app/assets/stylesheets/trestle/components/_scopes.scss +11 -2
  12. data/app/assets/stylesheets/trestle/components/_table.scss +34 -10
  13. data/app/assets/stylesheets/trestle/components/_timestamp.scss +4 -1
  14. data/app/assets/stylesheets/trestle/components/_toolbars.scss +55 -0
  15. data/app/assets/stylesheets/trestle/core/_defaults.scss +13 -2
  16. data/app/assets/stylesheets/trestle/core/_mixins.scss +11 -0
  17. data/app/helpers/trestle/form_helper.rb +1 -5
  18. data/app/helpers/trestle/hook_helper.rb +10 -6
  19. data/app/helpers/trestle/timestamp_helper.rb +49 -7
  20. data/app/helpers/trestle/toolbars_helper.rb +34 -0
  21. data/app/views/layouts/trestle/admin.html.erb +2 -2
  22. data/app/views/trestle/application/_dialog.html.erb +8 -10
  23. data/app/views/trestle/application/_header.html.erb +22 -20
  24. data/app/views/trestle/resource/edit.html.erb +4 -6
  25. data/app/views/trestle/resource/index.html.erb +15 -6
  26. data/app/views/trestle/resource/new.html.erb +2 -2
  27. data/app/views/trestle/resource/show.html.erb +4 -6
  28. data/app/views/trestle/shared/_sidebar.html.erb +3 -1
  29. data/app/views/trestle/shared/_title.html.erb +14 -0
  30. data/config/locales/en.yml +2 -0
  31. data/config/locales/es-MX.yml +94 -0
  32. data/config/locales/es.yml +94 -0
  33. data/config/locales/lv.rb +18 -0
  34. data/config/locales/lv.yml +94 -0
  35. data/lib/generators/trestle/install/templates/trestle.rb.erb +12 -2
  36. data/lib/trestle.rb +2 -0
  37. data/lib/trestle/configuration.rb +9 -3
  38. data/lib/trestle/engine.rb +5 -3
  39. data/lib/trestle/form/fields/form_control.rb +14 -4
  40. data/lib/trestle/form/renderer.rb +2 -2
  41. data/lib/trestle/hook.rb +27 -0
  42. data/lib/trestle/table/actions_column.rb +31 -26
  43. data/lib/trestle/table/column.rb +1 -0
  44. data/lib/trestle/toolbar.rb +43 -0
  45. data/lib/trestle/toolbar/builder.rb +52 -0
  46. data/lib/trestle/toolbar/context.rb +39 -0
  47. data/lib/trestle/version.rb +1 -1
  48. metadata +13 -3
  49. data/app/helpers/trestle/title_helper.rb +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5f74ea1864e543221e224711053214f59d7ebaaa302ae105a566e6105dc8486
4
- data.tar.gz: a3fd93cbc5acb0bacd23cc4354a0c6d2875709c20f84222d5c6a461e38b19505
3
+ metadata.gz: 499a6802f0891311253e5a4999b494715ccdfa8d070bae35827268044fc5a7f8
4
+ data.tar.gz: 5ac6a1b33a8b33ae636a7c948adc42d73212f6fba90b7ea71953a69b961f4723
5
5
  SHA512:
6
- metadata.gz: a821671d5f9f3d1fc49ce3bde54890957c0562def8d512f016c8860ad6aa8f39bdbeb38dd821f587819db3e90bb2f239f187d81fdb22dfc28ec2be58b20790d3
7
- data.tar.gz: 49fc89e2f174f9988ca56ba168b2b229b72bde4a8de88d2936b8e9712cbe87fa166d52211d11576d6dfe5e2ea0ed3a8f2393b250c2a7424bbf19fbe89c401d30
6
+ metadata.gz: aef9565030e42e5fe42dd0a0773c65b1eb35a41c743678a1799ae57df99e438f7d61c3cb74b905171ff844134176f9a1c95a21ff917e6e25e072b494d1d776bb
7
+ data.tar.gz: 4971e16e2e693081c8ed4d20a53bf4ce980261e66c0370c208356eadd41877f411290a8c81f5e0e5a796e5cfa70ff17a2cb5ab7b5b74848e658806d99cb89646
@@ -1,3 +1,29 @@
1
+ Trestle.confirmation = {};
2
+
3
+ Trestle.confirmation.DEFAULTS = {
4
+ rootSelector: 'body',
5
+ singleton: true,
6
+ popout: true,
7
+ title: Trestle.i18n['admin.confirmation.title'] || 'Are you sure?',
8
+ btnOkIcon: '',
9
+ btnOkClass: 'btn-primary',
10
+ btnOkLabel: Trestle.i18n['admin.confirmation.ok'] || 'OK',
11
+ btnCancelIcon: '',
12
+ btnCancelClass: 'btn-default',
13
+ btnCancelLabel: Trestle.i18n['admin.confirmation.cancel'] || 'Cancel',
14
+ copyAttributes: ''
15
+ };
16
+
17
+ Trestle.confirmation.CONFIRM = $.extend({}, Trestle.confirmation.DEFAULTS, {
18
+ selector: '[data-toggle="confirm"]'
19
+ });
20
+
21
+ Trestle.confirmation.DELETE = $.extend({}, Trestle.confirmation.DEFAULTS, {
22
+ selector: '[data-toggle="confirm-delete"]',
23
+ btnOkClass: 'btn-danger',
24
+ btnOkLabel: Trestle.i18n['admin.confirmation.delete'] || 'Delete'
25
+ });
26
+
1
27
  Trestle.ready(function() {
2
28
  // This must be bound to an element beneath document so
3
29
  // that it is fired before any jquery_ujs events.
@@ -6,18 +32,9 @@ Trestle.ready(function() {
6
32
  // Ensure it is only initialized once
7
33
  if (root.data('bs.confirmation')) return;
8
34
 
9
- root.confirmation({
10
- rootSelector: 'body',
11
- selector: '[data-toggle="confirm-delete"]',
12
- singleton: true,
13
- popout: true,
14
- title: Trestle.i18n['admin.confirmation.title'] || 'Are you sure?',
15
- btnOkIcon: '',
16
- btnOkClass: 'btn-danger',
17
- btnOkLabel: Trestle.i18n['admin.confirmation.delete'] || 'Delete',
18
- btnCancelIcon: '',
19
- btnCancelClass: 'btn-default',
20
- btnCancelLabel: Trestle.i18n['admin.confirmation.cancel'] || 'Cancel',
21
- copyAttributes: ''
22
- });
35
+ // Delete confirmation
36
+ new $.fn.confirmation.Constructor(root, Trestle.confirmation.DELETE);
37
+
38
+ // General confirmation
39
+ new $.fn.confirmation.Constructor(root, Trestle.confirmation.CONFIRM);
23
40
  });
@@ -9,13 +9,24 @@ Trestle.init(function(e, root) {
9
9
  var form = $(root).find('form[data-behavior="trestle-form"]');
10
10
 
11
11
  form
12
+ .on('ajax:send', function(e, xhr) {
13
+ // Disable submit buttons
14
+ $(this).find(':submit').prop('disabled', true);
15
+
16
+ // Set loading status on button that triggered submission
17
+ var button = $(this).data('trestle:submitButton');
18
+ if (button) { $(button).addClass('loading'); }
19
+ })
12
20
  .on('ajax:complete', function(e, xhr, status) {
13
- var contentType = xhr.getResponseHeader("Content-Type").split(";")[0];
21
+ // Reset submit buttons
22
+ $(this).find(':submit').prop('disabled', false).removeClass('loading');
23
+ $(this).removeData('trestle:submitButton');
14
24
 
15
- if (contentType == "text/html") {
25
+ var contentType = xhr.getResponseHeader("Content-Type");
26
+
27
+ if (contentType && contentType.split(";")[0] == "text/html") {
16
28
  if (/<html/i.test(xhr.responseText)) {
17
29
  // Response is a full HTML page, likely an error page. Render within an iframe.
18
-
19
30
  var context = $(this).closest('[data-context]');
20
31
  var iframe = $("<iframe>").addClass('error-iframe').get(0);
21
32
  context.html(iframe);
@@ -36,9 +47,6 @@ Trestle.init(function(e, root) {
36
47
  // Assume an error response
37
48
  var title = xhr.status + " (" + xhr.statusText + ")";
38
49
  Trestle.Dialog.showError(title, xhr.responseText);
39
-
40
- // Reset submit button
41
- form.find(':submit').prop('disabled', false).removeClass('loading');
42
50
  }
43
51
  })
44
52
  .on('ajax:success', function(e, data, status, xhr) {
@@ -46,6 +54,9 @@ Trestle.init(function(e, root) {
46
54
  var location = xhr.getResponseHeader("X-Trestle-Location");
47
55
 
48
56
  if (location) {
57
+ // Retain current active tab
58
+ location = location + document.location.hash;
59
+
49
60
  // Update the URL in the browser and context
50
61
  history.replaceState({}, "", location);
51
62
  context.data('context', location);
@@ -57,15 +68,8 @@ Trestle.init(function(e, root) {
57
68
  }
58
69
  });
59
70
 
60
- // Loading indicator
61
71
  form.find(':submit').click(function() {
62
- var button = $(this);
63
-
64
- // Delay to ensure form is still submitted
65
- setTimeout(function() {
66
- if (form[0].checkValidity()) {
67
- button.prop('disabled', true).addClass('loading');
68
- }
69
- }, 1);
72
+ // Save this as the button that triggered the form
73
+ $(this).closest('form').data('trestle:submitButton', this);
70
74
  });
71
75
  });
@@ -20,6 +20,6 @@ Trestle.focusActiveTab = function() {
20
20
  }
21
21
  };
22
22
 
23
- Trestle.ready(function() {
23
+ Trestle.init(function() {
24
24
  Trestle.focusActiveTab();
25
25
  });
@@ -3,6 +3,14 @@
3
3
  background-color: transparent;
4
4
  font-size: 12px;
5
5
 
6
+ > li + li:before {
7
+ content: "/";
8
+
9
+ @include mobile {
10
+ padding: 0 2px;
11
+ }
12
+ }
13
+
6
14
  .active, .active a {
7
15
  font-weight: normal;
8
16
  color: $breadcrumb-active-color;
@@ -11,4 +19,8 @@
11
19
  text-decoration: none;
12
20
  }
13
21
  }
22
+
23
+ @include mobile {
24
+ font-size: 11px;
25
+ }
14
26
  }
@@ -1,5 +1,72 @@
1
+ @mixin button-child-visible($prefix, $selector) {
2
+ &.#{$prefix}-visible-xs,
3
+ &.#{$prefix}-visible-sm,
4
+ &.#{$prefix}-visible-md,
5
+ &.#{$prefix}-visible-lg {
6
+ #{$selector} { display: none; }
7
+ }
8
+
9
+ &.#{$prefix}-visible-xs {
10
+ @media (max-width: $screen-xs-max) {
11
+ #{$selector} { display: inline-block; }
12
+ @content;
13
+ }
14
+ }
15
+
16
+ &.#{$prefix}-visible-sm {
17
+ @media (min-width: $screen-sm-min) and (max-width: $screen-sm-max) {
18
+ #{$selector} { display: inline-block; }
19
+ @content;
20
+ }
21
+ }
22
+
23
+ &.#{$prefix}-visible-md {
24
+ @media (min-width: $screen-md-min) and (max-width: $screen-md-max) {
25
+ #{$selector} { display: inline-block; }
26
+ @content;
27
+ }
28
+ }
29
+
30
+ &.#{$prefix}-visible-lg {
31
+ @media (min-width: $screen-lg-min) {
32
+ #{$selector} { display: inline-block; }
33
+ @content;
34
+ }
35
+ }
36
+ }
37
+
38
+ @mixin button-child-hidden($prefix, $selector) {
39
+ &.#{$prefix}-hidden-xs {
40
+ @media (max-width: $screen-xs-max) {
41
+ #{$selector} { display: none; }
42
+ @content;
43
+ }
44
+ }
45
+
46
+ &.#{$prefix}-hidden-sm {
47
+ @media (min-width: $screen-sm-min) and (max-width: $screen-sm-max) {
48
+ #{$selector} { display: none; }
49
+ @content;
50
+ }
51
+ }
52
+
53
+ &.#{$prefix}-hidden-md {
54
+ @media (min-width: $screen-md-min) and (max-width: $screen-md-max) {
55
+ #{$selector} { display: none; }
56
+ @content;
57
+ }
58
+ }
59
+
60
+ &.#{$prefix}-hidden-lg {
61
+ @media (min-width: $screen-lg-min) {
62
+ #{$selector} { display: none; }
63
+ @content;
64
+ }
65
+ }
66
+ }
67
+
1
68
  .btn {
2
- border: none;
69
+ border-width: 0;
3
70
  box-shadow: none;
4
71
 
5
72
  &.loading {
@@ -10,6 +77,34 @@
10
77
  margin-right: 10px;
11
78
  }
12
79
  }
80
+
81
+ > i + .btn-label {
82
+ margin-left: 5px;
83
+ }
84
+
85
+ &.icon-visible-xs,
86
+ &.icon-visible-sm,
87
+ &.icon-visible-md,
88
+ &.icon-visible-lg {
89
+ > i + .btn-label {
90
+ margin-left: 0;
91
+ }
92
+ }
93
+
94
+ @include button-child-visible('icon', '> i') {
95
+ > i + .btn-label {
96
+ margin-left: 5px;
97
+ }
98
+ };
99
+
100
+ @include button-child-hidden('icon', '> i') {
101
+ > i + .btn-label {
102
+ margin-left: 0;
103
+ }
104
+ };
105
+
106
+ @include button-child-visible('label', '> .btn-label');
107
+ @include button-child-hidden('label', '> .btn-label');
13
108
  }
14
109
 
15
110
  .btn-delete {
@@ -20,3 +115,9 @@
20
115
  background: $btn-danger-bg;
21
116
  }
22
117
  }
118
+
119
+ .btn-new-resource {
120
+ .btn-label {
121
+ @include sr-only;
122
+ }
123
+ }
@@ -1,38 +1,32 @@
1
1
  .content-header {
2
- @extend .clearfix;
2
+ display: flex;
3
+ justify-content: space-between;
4
+
3
5
  background: $content-header-background;
4
- padding: 5px 20px;
6
+ padding: 20px;
5
7
 
6
8
  h1 {
7
9
  font-weight: 300;
10
+ margin-top: 0;
8
11
  }
9
12
 
10
- .btn-toolbar {
11
- @extend .pull-right;
12
- clear: right;
13
+ .breadcrumb {
14
+ margin-bottom: 0;
13
15
  }
14
16
 
15
- .primary-toolbar {
16
- margin-top: 16px;
17
+ .content-header-title {
18
+ margin: 5px 0;
19
+ }
17
20
 
18
- .btn {
19
- @extend .btn-lg;
20
- font-size: 20px;
21
- padding: 8px 16px;
22
- border-radius: $border-radius-base;
23
- }
21
+ .btn-toolbar {
22
+ text-align: right;
24
23
  }
25
24
 
26
25
  .secondary-toolbar {
27
26
  margin-top: 8px;
28
27
 
29
- .btn {
30
- font-size: 12px;
31
- padding: 4px 10px;
32
-
33
- i {
34
- font-size: 11px;
35
- }
28
+ @include mobile {
29
+ margin-top: 6px;
36
30
  }
37
31
  }
38
32
  }
@@ -59,6 +53,20 @@
59
53
  min-width: 0;
60
54
  }
61
55
 
56
+ .main-content-header {
57
+ margin: -20px -20px 20px !important;
58
+ padding: $main-content-header-padding;
59
+ background: $main-content-header-background;
60
+ border-bottom: $main-content-header-border;
61
+ }
62
+
63
+ .main-content-footer {
64
+ margin: 20px -20px -20px !important;
65
+ padding: $main-content-footer-padding;
66
+ background: $main-content-footer-background;
67
+ border-top: $main-content-footer-border;
68
+ }
69
+
62
70
  .main-content,
63
71
  .main-content-sidebar,
64
72
  .tab-pane {
@@ -84,7 +92,7 @@
84
92
 
85
93
  @include mobile {
86
94
  .content-header {
87
- padding: 0 10px;
95
+ padding: 10px;
88
96
  }
89
97
 
90
98
  .main-content-area {
@@ -105,4 +113,16 @@
105
113
  .main-content-sidebar {
106
114
  padding: 15px;
107
115
  }
116
+
117
+ .main-content-header {
118
+ margin: -15px -15px 15px !important;
119
+ padding-left: 15px;
120
+ padding-right: 15px;
121
+ }
122
+
123
+ .main-content-footer {
124
+ margin: 15px -15px -15px !important;
125
+ padding-left: 15px;
126
+ padding-right: 15px;
127
+ }
108
128
  }
@@ -22,8 +22,15 @@
22
22
  }
23
23
  }
24
24
 
25
- .input-group-addon {
25
+ .input-group-addon,
26
+ .input-group-btn {
26
27
  width: auto;
27
28
  display: flex;
28
29
  align-items: center;
29
30
  }
31
+
32
+ .input-group-btn {
33
+ > .btn {
34
+ border-width: 1px;
35
+ }
36
+ }
@@ -86,6 +86,9 @@
86
86
  }
87
87
 
88
88
  .modal-footer {
89
+ background: $modal-footer-background;
90
+ border-color: $modal-footer-border-color;
91
+
89
92
  .primary-toolbar {
90
93
  float: right;
91
94
  }
@@ -1,6 +1,4 @@
1
1
  .pagination-container {
2
- margin-top: 20px;
3
- margin-bottom: 20px;
4
2
  text-align: right;
5
3
 
6
4
  p {
@@ -26,7 +24,6 @@
26
24
 
27
25
  @include mobile {
28
26
  .pagination-container {
29
- margin-top: 10px;
30
27
  text-align: center;
31
28
 
32
29
  display: flex;
@@ -3,9 +3,17 @@
3
3
  @extend .nav-pills;
4
4
 
5
5
  display: flex;
6
+ flex-wrap: wrap;
6
7
 
7
- > li + li {
8
- margin-left: 4px;
8
+ margin-top: -4px;
9
+
10
+ > li {
11
+ margin-top: 4px;
12
+ margin-right: 4px;
13
+
14
+ &:last-child {
15
+ margin-right: 0;
16
+ }
9
17
  }
10
18
 
11
19
  > li > a {
@@ -14,6 +22,7 @@
14
22
 
15
23
  font-size: 11px;
16
24
  font-weight: normal;
25
+ white-space: nowrap;
17
26
 
18
27
  border-radius: 15px;
19
28
  padding: 2px 8px;