tao_ui 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/config/locales/tao_ui/components/tree/en.yml +6 -0
  3. data/config/locales/tao_ui/components/tree/zh-CN.yml +6 -0
  4. data/lib/assets/javascripts/tao/ui/dialog/index.coffee +11 -1
  5. data/lib/assets/javascripts/tao/ui/index.coffee +3 -0
  6. data/lib/assets/javascripts/tao/ui/mobile/slide_box/index.coffee +1 -3
  7. data/lib/assets/javascripts/tao/ui/popover/index.coffee +11 -1
  8. data/lib/assets/javascripts/tao/ui/shared/slide_box/export.coffee +11 -0
  9. data/lib/assets/javascripts/tao/ui/slide_box/index.coffee +1 -3
  10. data/lib/assets/javascripts/tao/ui/sortable.coffee +140 -0
  11. data/lib/assets/javascripts/tao/ui/table/element.coffee +13 -0
  12. data/lib/assets/javascripts/tao/ui/table/expandable.coffee +61 -0
  13. data/lib/assets/javascripts/tao/ui/table/index.coffee +6 -0
  14. data/lib/assets/javascripts/tao/ui/table/selectable.coffee +52 -0
  15. data/lib/assets/javascripts/tao/ui/tree/element.coffee +58 -0
  16. data/lib/assets/javascripts/tao/ui/tree/index.coffee +5 -0
  17. data/lib/assets/javascripts/tao/ui/tree/item.coffee +86 -0
  18. data/lib/assets/stylesheets/tao/ui/index.scss +2 -0
  19. data/lib/assets/stylesheets/tao/ui/mobile/buttons.scss +6 -0
  20. data/lib/assets/stylesheets/tao/ui/mobile/slide_box.scss +1 -1
  21. data/lib/assets/stylesheets/tao/ui/shared/_buttons.scss +1 -1
  22. data/lib/assets/stylesheets/tao/ui/shared/_tables.scss +3 -2
  23. data/lib/assets/stylesheets/tao/ui/shared/variables/_base.scss +1 -0
  24. data/lib/assets/stylesheets/tao/ui/shared/variables/_buttons.scss +1 -1
  25. data/lib/assets/stylesheets/tao/ui/shared/variables/_tables.scss +2 -0
  26. data/lib/assets/stylesheets/tao/ui/sortable.scss +16 -0
  27. data/lib/assets/stylesheets/tao/ui/tables.scss +77 -0
  28. data/lib/assets/stylesheets/tao/ui/tree.scss +126 -0
  29. data/lib/tao_ui/action_view/helpers.rb +23 -0
  30. data/lib/tao_ui/components.rb +3 -0
  31. data/lib/tao_ui/components/icon_component.rb +0 -2
  32. data/lib/tao_ui/components/slide_box_component.rb +0 -2
  33. data/lib/tao_ui/components/sortable_component.rb +17 -0
  34. data/lib/tao_ui/components/table/base_builder.rb +58 -0
  35. data/lib/tao_ui/components/table/body_builder.rb +30 -0
  36. data/lib/tao_ui/components/table/head_builder.rb +15 -0
  37. data/lib/tao_ui/components/table/row_builder.rb +53 -0
  38. data/lib/tao_ui/components/table/table_builder.rb +35 -0
  39. data/lib/tao_ui/components/table_component.rb +40 -0
  40. data/lib/tao_ui/components/tree/item_component.rb +121 -0
  41. data/lib/tao_ui/components/tree/list_component.rb +51 -0
  42. data/lib/tao_ui/components/tree_component.rb +43 -0
  43. data/lib/tao_ui/engine.rb +7 -0
  44. data/lib/tao_ui/version.rb +1 -1
  45. data/lib/views/components/tao_ui/components/_confirm_dialog.html.erb +2 -2
  46. data/lib/views/components/tao_ui/components/_confirm_popover.html.erb +2 -2
  47. data/lib/views/components/tao_ui/components/_message_dialog.html.erb +1 -1
  48. metadata +26 -2
@@ -0,0 +1,86 @@
1
+ class Tao.Tree.Item extends TaoComponent
2
+
3
+ @tag 'tao-tree-item'
4
+
5
+ @attribute 'depth', type: 'number'
6
+
7
+ @attribute 'expandable', 'selectable', type: 'boolean'
8
+
9
+ @attribute 'expanded', 'selected', 'indeterminate', type: 'boolean', observe: true
10
+
11
+ @attribute 'remote', type: 'hash'
12
+
13
+ _connected: ->
14
+ @checkbox = @findComponent '> .tao-tree-item-content tao-check-box', =>
15
+ @_selectedChanged() if @selected
16
+ @_bind()
17
+
18
+ _disconnected: ->
19
+ @off()
20
+ @checkbox.off()
21
+ @checkbox = null
22
+
23
+ _bind: ->
24
+ @on 'click', '> .tao-tree-item-content > .link-toggle-item', (e) =>
25
+ @_toggleExpanded() if @expandable && !@jq.hasClass('expanding')
26
+ null
27
+
28
+ @checkbox.on 'tao:change', (e) =>
29
+ @selected = e.currentTarget.checked
30
+ @trigger 'tao-tree-item:selectedChange', [@selected]
31
+ null
32
+
33
+ _beforeExpandedChanged: (expanded) ->
34
+ $list = @jq.find('> .tao-tree-list')
35
+ @jq.addClass 'expanding'
36
+ $list.css 'display', 'block'
37
+ $list.css 'height', if expanded then '0' else $list.get(0).scrollHeight
38
+ $list.one 'transitionend', => @_afterTransition()
39
+ @reflow()
40
+ null
41
+
42
+ _expandedChanged: ->
43
+ $list = @jq.find('> .tao-tree-list')
44
+ if @expanded
45
+ $list.css 'height', $list.get(0).scrollHeight
46
+ else
47
+ $list.css 'height', '0'
48
+
49
+ _selectedChanged: ->
50
+ return unless @selectable
51
+ @checkbox.checked = @selected
52
+ null
53
+
54
+ _indeterminateChanged: ->
55
+ return unless @selectable
56
+ @checkbox.indeterminate = @indeterminate
57
+ null
58
+
59
+ _afterTransition: ->
60
+ $list = @jq.find('> .tao-tree-list')
61
+ @jq.removeClass 'expanding'
62
+ if @expanded
63
+ $list.css 'height', 'auto'
64
+ if @remote && $list.find('> .tao-tree-loading').length > 0
65
+ @_requestList()
66
+ else
67
+ $list.hide()
68
+
69
+ _toggleExpanded: ->
70
+ @expanded = !@expanded
71
+
72
+ _requestList: ->
73
+ $.ajax
74
+ url: @remote.url
75
+ type: 'get'
76
+ data: _.extend {}, @remote.params,
77
+ depth: @depth
78
+ selectable: @selectable || undefined
79
+ selected: @selected || undefined
80
+ dataType: 'script'
81
+
82
+ updateList: ($newList) ->
83
+ @_afterTransition() if @jq.hasClass('expanding')
84
+ @jq.find('> .tao-tree-list').replaceWith($newList)
85
+
86
+ TaoComponent.register Tao.Tree.Item
@@ -8,3 +8,5 @@
8
8
  //= require ./popover
9
9
  //= require ./tooltip
10
10
  //= require ./dialog
11
+ //= require ./sortable
12
+ //= require ./tree
@@ -1,2 +1,8 @@
1
1
  @import 'tao/ui/mobile/globals';
2
2
  @import 'tao/ui/shared/buttons';
3
+
4
+ .button {
5
+ &.text-with-icon {
6
+ padding-left: 1.125em;
7
+ }
8
+ }
@@ -25,7 +25,7 @@ tao-slide-box {
25
25
  }
26
26
 
27
27
  .title {
28
- flex: 1 1 auto;
28
+ flex: 0 0 auto;
29
29
  text-align: center;
30
30
  }
31
31
 
@@ -18,7 +18,7 @@
18
18
  }
19
19
 
20
20
  &.text-with-icon {
21
- padding-left: 1.125em;
21
+ padding-left: 1.5em;
22
22
 
23
23
  .icon {
24
24
  margin-right: 0.5em
@@ -2,11 +2,12 @@ table.table {
2
2
  width: 100%;
3
3
  max-width: 100%;
4
4
  border-collapse: collapse;
5
+ table-layout: fixed;
5
6
 
6
7
  th {
7
8
  border-top: 1px solid $table-line-color;
8
9
  border-bottom: 1px solid $table-line-color;
9
- padding: 0.875rem 0.625rem;
10
+ padding: $table-th-padding;
10
11
  font-size: $font-size-xs;
11
12
  font-weight: normal;
12
13
  line-height: 1.125;
@@ -16,7 +17,7 @@ table.table {
16
17
 
17
18
  td {
18
19
  border-bottom: 1px solid $table-line-color;
19
- padding: 1.125rem 0.625rem;
20
+ padding: $table-td-padding;
20
21
  line-height: 1.125;
21
22
  text-align: left;
22
23
  }
@@ -8,6 +8,7 @@ $red-color: #ff7755 !default;
8
8
  $orange-color: #ffaa00 !default;
9
9
  $green-color: #55bb33 !default;
10
10
  $blue-color: #22bbff !default;
11
+ $grey-blue-color: #7AA4D4 !default;
11
12
 
12
13
  $light-grey-color: #666666 !default;
13
14
  $lighter-grey-color: #9b9b9b !default;
@@ -7,7 +7,7 @@ $button-warn-active-color: #EE6633 !default;
7
7
  $button-font-size: 1rem !default;
8
8
  $button-line-height: 1.5 !default;
9
9
  $button-padding-v: 0.4375em !default;
10
- $button-padding-h: 1.25em !default;
10
+ $button-padding-h: 1.875em !default;
11
11
  $button-padding: $button-padding-v $button-padding-h !default;
12
12
 
13
13
  $small-button-font-size: 0.75rem !default;
@@ -1,2 +1,4 @@
1
1
  $table-line-color: $light-line-color !default;
2
2
  $table-row-hover-color: $grey-bg-color !default;
3
+ $table-th-padding: 0.875rem 0.625rem !default;
4
+ $table-td-padding: 1.125rem 0.625rem !default;
@@ -0,0 +1,16 @@
1
+ @import 'tao/ui/globals';
2
+
3
+ .tao-sortable {
4
+
5
+ [draggable='true'] {
6
+ cursor: move;
7
+ user-select: none;
8
+ /* Required to make elements draggable in old WebKit */
9
+ -khtml-user-drag: element;
10
+ -webkit-user-drag: element;
11
+ }
12
+
13
+ .tao-sortable-sorting {
14
+ visibility: hidden !important;
15
+ }
16
+ }
@@ -6,3 +6,80 @@ table.table {
6
6
  background-color: $table-row-hover-color;
7
7
  }
8
8
  }
9
+
10
+ .tao-table {
11
+ .th-checkbox,
12
+ .td-checkbox {
13
+ display: none;
14
+ width: 2.5rem;
15
+ padding: 0;
16
+ text-align: center;
17
+ }
18
+
19
+ &[selectable] {
20
+ .th-checkbox,
21
+ .td-checkbox {
22
+ display: table-cell;
23
+ }
24
+ }
25
+
26
+ .th-expand-icon,
27
+ .td-expand-icon {
28
+ display: none;
29
+ width: 2.5rem;
30
+ padding: 0;
31
+ text-align: center;
32
+ }
33
+
34
+ &[expandable] {
35
+
36
+ .th-expand-icon,
37
+ .td-expand-icon {
38
+ display: table-cell;
39
+
40
+ .icon {
41
+ width: 1rem;
42
+ height: 1rem;
43
+ transition: transform 200ms;
44
+ }
45
+ }
46
+
47
+ tr.expandable {
48
+ .td-expand-icon .icon {
49
+ fill: $lighter-grey-color;
50
+ }
51
+
52
+ &:hover .td-expand-icon .icon {
53
+ fill: $grey-color;
54
+ }
55
+ }
56
+
57
+ tr.expanded {
58
+ border-bottom-color: transparent;
59
+
60
+ .th-expand-icon,
61
+ .td-expand-icon {
62
+ .icon {
63
+ transform: rotate(90deg);
64
+ }
65
+ }
66
+ }
67
+
68
+ tr.expandable-panel {
69
+ display: none;
70
+ background: $grey-bg-color;
71
+
72
+ & > td {
73
+ padding: 0;
74
+ box-shadow: inset 0 8px 10px -8px rgba(184, 184, 184, 0.8);
75
+
76
+ & > div:first-child {
77
+ padding: 1.5rem 2rem;
78
+ height: 0;
79
+ transition: height 200ms linear;
80
+ overflow-y: hidden;
81
+ }
82
+ }
83
+ }
84
+ }
85
+ }
@@ -0,0 +1,126 @@
1
+ @import 'tao/ui/globals';
2
+
3
+ $tree-item-height: 2rem !default;
4
+ $tree-item-font-size: 0.875rem !default;
5
+
6
+ .tao-tree {
7
+
8
+ .tao-tree-item {
9
+ display: block;
10
+
11
+ .tao-tree-item-padding {
12
+ height: 100%;
13
+ display: flex;
14
+
15
+ .padding-item {
16
+ position: relative;
17
+ height: 100%;
18
+ width: 2rem;
19
+
20
+ &:before {
21
+ content: '';
22
+ display: block;
23
+ border-left: 1px solid $light-border-color;
24
+ position: absolute;
25
+ left: 0.625rem;
26
+ top: 0;
27
+ right: 0;
28
+ bottom: 0;
29
+ }
30
+
31
+ &:last-child:after {
32
+ content: '';
33
+ display: block;
34
+ border-bottom: 1px solid $light-border-color;
35
+ position: absolute;
36
+ left: 0.625rem;
37
+ top: 0;
38
+ right: 0.5rem;
39
+ bottom: 50%;
40
+ }
41
+ }
42
+ }
43
+
44
+ &:last-child > .tao-tree-item-content .tao-tree-item-padding .padding-item:last-child:before {
45
+ bottom: 50%;
46
+ }
47
+
48
+ & > .tao-tree-item-content {
49
+ display: flex;
50
+ align-items: center;
51
+ height: $tree-item-height;
52
+ line-height: $tree-item-height;
53
+ font-size: $tree-item-font-size;
54
+
55
+ .link-toggle-item {
56
+ display: block;
57
+ background: $white-color;
58
+ width: 1.375rem;
59
+ height: 1.375rem;
60
+ padding: 0.25rem;
61
+ transition: transform 200ms;
62
+ border: 1px solid $border-color;
63
+ border-radius: 50%;
64
+ margin: 0 0.75rem 0 0;
65
+ cursor: pointer;
66
+ visibility: hidden;
67
+
68
+ .icon {
69
+ display: block;
70
+ width: 0.75rem;
71
+ height: 0.75rem;
72
+ fill: $lighter-grey-color;
73
+ }
74
+
75
+ &:hover {
76
+ background: $grey-bg-color;
77
+
78
+ .icon {
79
+ fill: $grey-color;
80
+ }
81
+ }
82
+ }
83
+
84
+ tao-check-box {
85
+ margin: 0 0.75rem 0 0;
86
+ }
87
+ }
88
+
89
+ & > .tao-tree-list {
90
+ display: none;
91
+ transition: height 200ms;
92
+ overflow: hidden;
93
+
94
+ & > .tao-tree-loading {
95
+ display: flex;
96
+ align-items: center;
97
+ height: $tree-item-height;
98
+ line-height: $tree-item-height;
99
+ font-size: $tree-item-font-size;
100
+ color: $lighter-grey-color;
101
+
102
+ .icon {
103
+ margin: 0 0.75rem 0 0;
104
+ }
105
+ }
106
+ }
107
+
108
+ &[expandable] {
109
+ & > .tao-tree-item-content .link-toggle-item {
110
+ visibility: visible;
111
+ }
112
+ }
113
+
114
+ &[expanded] {
115
+ & > .tao-tree-item-content .link-toggle-item {
116
+ transform: rotate(90deg);
117
+ }
118
+
119
+ & > .tao-tree-list {
120
+ display: block;
121
+ height: auto;
122
+ }
123
+ }
124
+ }
125
+
126
+ }
@@ -0,0 +1,23 @@
1
+ module TaoUi
2
+ module ActionView
3
+ module Helpers
4
+
5
+ def tao_table_builder options = {}
6
+ TaoUi::Components::Table::TableBuilder.new self, options
7
+ end
8
+
9
+ def tao_table_head_builder options = {}
10
+ TaoUi::Components::Table::HeadBuilder.new self, options
11
+ end
12
+
13
+ def tao_table_body_builder options = {}
14
+ TaoUi::Components::Table::BodyBuilder.new self, options
15
+ end
16
+
17
+ def tao_table_row_builder options = {}
18
+ TaoUi::Components::Table::RowBuilder.new self, options
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -1,4 +1,5 @@
1
1
  require 'tao_ui/components/icon_component'
2
+ require 'tao_ui/components/table_component'
2
3
  require 'tao_ui/components/slide_box_component'
3
4
  require 'tao_ui/components/popover_component'
4
5
  require 'tao_ui/components/tooltip_component'
@@ -6,3 +7,5 @@ require 'tao_ui/components/confirm_popover_component'
6
7
  require 'tao_ui/components/dialog_component'
7
8
  require 'tao_ui/components/message_dialog_component'
8
9
  require 'tao_ui/components/confirm_dialog_component'
10
+ require 'tao_ui/components/sortable_component'
11
+ require 'tao_ui/components/tree_component'
@@ -1,5 +1,3 @@
1
- require 'tao_on_rails/components/base'
2
-
3
1
  module TaoUi
4
2
  module Components
5
3
  class IconComponent < TaoOnRails::Components::Base
@@ -1,5 +1,3 @@
1
- require 'tao_on_rails/components/base'
2
-
3
1
  module TaoUi
4
2
  module Components
5
3
  class SlideBoxComponent < TaoOnRails::Components::Base