promethee 1.3.2 → 1.3.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.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/app/assets/stylesheets/promethee-edit/_move.sass +6 -4
  4. data/app/views/promethee/_edit.html.erb +14 -6
  5. data/app/views/promethee/components/aside/_edit.define.html.erb +14 -151
  6. data/app/views/promethee/components/aside/_icon.svg +3 -0
  7. data/app/views/promethee/components/column/_edit.define.html.erb +17 -31
  8. data/app/views/promethee/components/column/_icon.svg +3 -0
  9. data/app/views/promethee/components/cover/_edit.define.html.erb +16 -151
  10. data/app/views/promethee/components/cover/_icon.svg +3 -0
  11. data/app/views/promethee/components/image/_edit.define.html.erb +17 -149
  12. data/app/views/promethee/components/image/_icon.svg +3 -0
  13. data/app/views/promethee/components/row/_edit.define.html.erb +14 -150
  14. data/app/views/promethee/components/row/_icon.svg +3 -0
  15. data/app/views/promethee/components/slider/_edit.define.html.erb +14 -150
  16. data/app/views/promethee/components/slider/_edit.inspect.html.erb +43 -1
  17. data/app/views/promethee/components/slider/_edit.move.html.erb +6 -2
  18. data/app/views/promethee/components/slider/_icon.svg +3 -0
  19. data/app/views/promethee/components/text/_edit.define.html.erb +15 -150
  20. data/app/views/promethee/components/text/_icon.svg +3 -0
  21. data/app/views/promethee/components/video/_edit.define.html.erb +14 -29
  22. data/app/views/promethee/components/video/_icon.svg +3 -0
  23. data/app/views/promethee/edit/_move.html.erb +48 -21
  24. data/app/views/promethee/presets/_icon.image-with-text.svg +3 -0
  25. data/app/views/promethee/presets/_image-with-text.html.erb +33 -0
  26. data/app/views/promethee/utils/_summernote-config.html.erb +11 -5
  27. data/lib/promethee/rails/helper.rb +4 -0
  28. data/lib/promethee/rails/version.rb +1 -1
  29. data/vendor/assets/javascripts/ui-sortable.js +683 -0
  30. metadata +14 -3
@@ -1,3 +1,45 @@
1
1
  <script type="text/ng-template" id="promethee/components/slider/edit/inspect">
2
- No option for slider.
2
+ <div ui-sortable ng-model="promethee.inspected.children">
3
+ <div
4
+ class="panel panel-default"
5
+ ng-repeat="component in promethee.inspected.children"
6
+ >
7
+ <div class="panel-body">
8
+ <div class="row">
9
+ <div class="col-xs-9">
10
+ <span class="label label-default">#{{$index + 1}}</span>
11
+ <span class="label label-info">{{component.type}}</span>
12
+ </div>
13
+ <div class="col-xs-3">
14
+ <ng-include src="'promethee/move/component'"></ng-include>
15
+ </div>
16
+ </div>
17
+ </div>
18
+ </div>
19
+ </div>
20
+
21
+ <div class="pull-right btn-toolbar" ng-controller="SliderInspectorController">
22
+ <span ng-repeat="definition in itemDefinitions" class="btn btn-default" ng-click="addItem(definition)">Add {{definition.name}}</span>
23
+ </div>
24
+ </script>
25
+
26
+ <script>
27
+ promethee.controller('SliderInspectorController', ['$scope', 'identifier', function($scope, identifier) {
28
+ var availableComponents = ['image', 'video'];
29
+
30
+ $scope.itemDefinitions = $scope.promethee.definitions.filter(function(definition) {
31
+ return availableComponents.includes(definition.data.type);
32
+ });
33
+
34
+ var clone = function(object) {
35
+ return JSON.parse(JSON.stringify(object));
36
+ }
37
+
38
+ $scope.addItem = function(definition) {
39
+ var item = JSON.parse(JSON.stringify(definition.data));
40
+ item.id = identifier.generate();
41
+
42
+ $scope.promethee.inspected.children.push(item);
43
+ }
44
+ }])
3
45
  </script>
@@ -1,7 +1,11 @@
1
1
  <script type="text/ng-template" id="promethee/components/slider/edit/move">
2
2
  <%= render 'promethee/edit/move.header', type: 'slider' %>
3
- <div ng-if="component.children.length > 0" ng-init="component = component.children[0]">
4
- <ng-include src="'promethee/move/component'"></ng-include>
3
+ <div class="header">Slider</div>
4
+ <div class="row">
5
+ <div class="col-md-2" ng-repeat-start="component in component.children">
6
+ <ng-include src="'promethee/move/component'"></ng-include>
7
+ </div>
8
+ <div class="clearfix" ng-if="$index%6 === 5" ng-repeat-end></div>
5
9
  </div>
6
10
  </div>
7
11
  </div>
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100">
2
+ <path fill="#FFF" d="M30.3,35.9 L30.3,64.4 L70.9,64.4 L70.9,35.9 L30.3,35.9 Z M71.9,34.9 L71.9,65.4 L29.3,65.4 L29.3,34.9 L71.9,34.9 Z M75,32 L75,68.2 L26.1,68.2 L26.1,32 L75,32 Z M73,34 L28.1,34 L28.1,66.2 L73,66.2 L73,34 Z M90,37.7 L77,37.7 L77,35.7 L92,35.7 L92,64.5 L77,64.5 L77,62.5 L90,62.5 L90,37.7 Z M11,62.5 L24,62.5 L24,64.5 L9,64.5 L9,35.7 L24,35.7 L24,37.7 L11,37.7 L11,62.5 Z"/>
3
+ </svg>
@@ -1,151 +1,16 @@
1
- <%
2
- icon = '
3
- <?xml version="1.0" encoding="utf-8"?>
4
- <!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
5
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
6
- viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve">
7
- <g id="Calque_10" display="none">
8
- <rect x="-1.5" y="-1.5" display="inline" fill="#76868E" width="103" height="103"/>
9
- </g>
10
- <g id="Calque_2" display="none">
11
- <rect x="18.9" y="28" display="inline" fill="none" stroke="#253742" stroke-miterlimit="10" width="62.1" height="44"/>
12
- <g display="inline">
13
- <path fill="#253742" d="M84.5,25v50h-69V25H84.5 M86.5,23h-73v54h73V23L86.5,23z"/>
14
- </g>
15
- <g display="inline">
16
- <polygon fill="#253742" points="47.2,44.6 47.2,55.4 56.3,50 "/>
17
- <g>
18
- <path fill="#253742" d="M50,41.6c4.6,0,8.4,3.8,8.4,8.4s-3.8,8.4-8.4,8.4s-8.4-3.8-8.4-8.4S45.4,41.6,50,41.6 M50,40.6
19
- c-5.2,0-9.4,4.2-9.4,9.4s4.2,9.4,9.4,9.4c5.2,0,9.4-4.2,9.4-9.4S55.2,40.6,50,40.6L50,40.6z"/>
20
- </g>
21
- </g>
22
- </g>
23
- <g id="Calque_3" display="none">
24
- <g display="inline">
25
- <g>
26
- <path fill="#253742" d="M71.4,25v50H28.6V25H71.4 M73.4,23H26.6v54h46.9V23L73.4,23z"/>
27
- </g>
28
- <g>
29
- <g>
30
- <circle fill="#253742" cx="37.8" cy="36.5" r="2"/>
31
- <line fill="none" stroke="#253742" stroke-miterlimit="10" x1="43.3" y1="36.5" x2="64.3" y2="36.5"/>
32
- </g>
33
- <g>
34
- <circle fill="#253742" cx="37.8" cy="45.5" r="2"/>
35
- <line fill="none" stroke="#253742" stroke-miterlimit="10" x1="43.3" y1="45.5" x2="64.3" y2="45.5"/>
36
- </g>
37
- <g>
38
- <circle fill="#253742" cx="37.8" cy="54.5" r="2"/>
39
- <line fill="none" stroke="#253742" stroke-miterlimit="10" x1="43.3" y1="54.5" x2="64.3" y2="54.5"/>
40
- </g>
41
- <g>
42
- <circle fill="#253742" cx="37.8" cy="63.5" r="2"/>
43
- <line fill="none" stroke="#253742" stroke-miterlimit="10" x1="43.3" y1="63.5" x2="64.3" y2="63.5"/>
44
- </g>
45
- </g>
46
- </g>
47
- </g>
48
- <g id="Calque_4" display="none">
49
- <g display="inline">
50
- <path fill="#253742" d="M63.9,20.3l10.5,11.8v47.7H25.7V20.3H63.9 M64.8,18.3H23.7v63.4h52.7V31.3L64.8,18.3L64.8,18.3z"/>
51
- </g>
52
- <g display="inline">
53
- <path fill="#253742" d="M67.9,24.3l2.4,2.4v49H29.7V24.3H67.9 M68.3,23.3H28.7v53.4h42.7V26.3L68.3,23.3L68.3,23.3z"/>
54
- </g>
55
- <polyline display="inline" fill="none" stroke="#253742" stroke-width="2" stroke-miterlimit="10" points="76.3,81.7 23.7,81.7
56
- 23.7,18.3 "/>
57
- <g display="inline">
58
- <polygon fill="#FFFFFF" points="64.3,30.3 64.3,20.7 73.9,30.3 "/>
59
- <path fill="#253742" d="M65.3,23.1l6.2,6.2h-6.2V23.1 M63.3,18.3v13h13L63.3,18.3L63.3,18.3z"/>
60
- </g>
61
- <g display="inline">
62
- <g>
63
- <path fill="#253742" d="M39.3,30.3L39.3,30.3c0.6,0,1.1,0.1,1.6,0.3c1,0.4,1.7,1.2,2.1,2.2c0.4,1,0.4,2.1-0.1,3.1
64
- c-0.6,1.4-2.1,2.4-3.7,2.4c-0.6,0-1.1-0.1-1.6-0.3c-2-0.9-2.9-3.3-2-5.3C36.3,31.2,37.8,30.3,39.3,30.3 M39.3,29.3
65
- c-1.9,0-3.7,1.1-4.6,3c-1.1,2.5,0,5.5,2.5,6.6c0.7,0.3,1.4,0.4,2,0.4c1.9,0,3.7-1.1,4.6-3c1.1-2.5,0-5.5-2.5-6.6
66
- C40.7,29.4,40,29.3,39.3,29.3L39.3,29.3z"/>
67
- </g>
68
- </g>
69
- <g display="inline">
70
- <path fill="#253742" d="M40.7,46.6L48,60.3l0.5,1l0.9-0.6L59.7,54l10.6,9.7v12.5L30,75.7l-0.1-16.5L40.7,46.6 M40.8,44.8l-12,14
71
- L29,76.7l42.4,0.6v-14L59.8,52.8l-11,7L40.8,44.8L40.8,44.8z"/>
72
- </g>
73
- </g>
74
- <g id="Calque_5" display="none">
75
- </g>
76
- <g id="Calque_6">
77
- <g>
78
- <path fill="#FFFFFF" d="M38.8,40.8c0-1.6-0.1-3.3-0.3-5.2c2.3,0.1,6.1,0.1,11.5,0.1c5.4,0,9.2,0,11.4-0.1
79
- c-0.2,1.9-0.3,3.7-0.3,5.2c0,1.4,0,2.5,0.1,3.3h-0.9c-0.2-2.1-0.5-3.7-0.8-4.7c-0.3-1-0.9-1.8-1.7-2.2c-0.8-0.5-2.1-0.7-3.7-0.7
80
- h-2.2v23.2c0,1.1,0.1,2,0.3,2.5c0.2,0.5,0.6,0.9,1.2,1.1c0.6,0.2,1.4,0.3,2.6,0.4v0.8c-1.4-0.1-3.4-0.1-6-0.1c-2.7,0-4.7,0-6,0.1
81
- v-0.8c1.2,0,2.1-0.2,2.6-0.4c0.6-0.2,0.9-0.6,1.2-1.1c0.2-0.5,0.3-1.3,0.3-2.5V36.5h-2.2c-1.7,0-2.9,0.2-3.7,0.7
82
- c-0.8,0.5-1.4,1.2-1.7,2.2c-0.3,1-0.6,2.6-0.8,4.7h-0.9C38.8,43.3,38.8,42.2,38.8,40.8z"/>
83
- </g>
84
- <polygon fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" points="63.5,23 26.6,23 26.6,77 73.4,77
85
- 73.4,32.4 "/>
86
- <polyline fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" points="62.5,23 62.5,32.4 72.4,32.4 "/>
87
- </g>
88
- <g id="Calque_7" display="none">
89
- <g display="inline">
90
- <path fill="#FFFFFF" d="M84,34v32H16V34H84 M86,32H14v36h72V32L86,32z"/>
91
- </g>
92
- <g display="inline">
93
- <g>
94
- <path fill="#FFFFFF" d="M27.8,38.7L27.8,38.7c0.6,0,1.1,0.1,1.6,0.3c1,0.4,1.7,1.2,2.1,2.2c0.4,1,0.4,2.1-0.1,3.1
95
- c-0.6,1.4-2.1,2.4-3.7,2.4c-0.6,0-1.1-0.1-1.6-0.3c-2-0.9-2.9-3.3-2-5.3C24.8,39.6,26.2,38.7,27.8,38.7 M27.8,37.7
96
- c-1.9,0-3.8,1.1-4.6,3c-1.1,2.5,0,5.5,2.5,6.6c0.7,0.3,1.4,0.4,2,0.4c1.9,0,3.8-1.1,4.6-3c1.1-2.5,0-5.5-2.5-6.6
97
- C29.2,37.9,28.5,37.7,27.8,37.7L27.8,37.7z"/>
98
- </g>
99
- </g>
100
- <polyline display="inline" fill="none" stroke="#FFFFFF" stroke-miterlimit="10" points="81.2,57 62.1,51.3 49,54.8 39.5,47.3
101
- 19.2,55 "/>
102
- <path display="inline" fill="none" stroke="#FFFFFF" stroke-miterlimit="10" d="M75.8,65.3"/>
103
- <path display="inline" fill="none" stroke="#FFFFFF" stroke-miterlimit="10" d="M25.4,65"/>
104
- <g display="inline">
105
- <path fill="#FFFFFF" d="M80.7,36.5v27H19.3v-27H80.7 M81.7,35.5H18.3v29h63.3V35.5L81.7,35.5z"/>
106
- </g>
107
- </g>
108
- <g id="Calque_8" display="none">
109
- <g display="inline">
110
- <path fill="none" stroke="#FFFFFF" stroke-miterlimit="10" d="M76.5,65.4"/>
111
- <rect x="29.3" y="35.3" fill="none" stroke="#FFFFFF" stroke-miterlimit="10" width="41.6" height="29.5"/>
112
- <g>
113
- <path fill="#FFFFFF" d="M72.5,33.9v32.2H27.6V33.9H72.5 M74.5,31.9H25.6v36.2h48.9V31.9L74.5,31.9z"/>
114
- </g>
115
- <polyline fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" points="76.5,36.6 90.5,36.6 90.5,63.4
116
- 76.5,63.4 "/>
117
- <polyline fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" points="23.5,63.4 9.5,63.4 9.5,36.6 23.5,36.6
118
- "/>
119
- </g>
120
- </g>
121
- <g id="Calque_9" display="none">
122
- <g display="inline">
123
- <g>
124
- <g>
125
- <path fill="#FFFFFF" d="M84.5,16.5v67h-69v-67H84.5 M86.5,14.5h-73v71h73V14.5L86.5,14.5z"/>
126
- </g>
127
- <line fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" x1="86.5" y1="31.5" x2="13.5" y2="31.5"/>
128
- <line fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" x1="23.5" y1="23.5" x2="30.5" y2="23.5"/>
129
- <line fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" x1="36.5" y1="23.5" x2="77.5" y2="23.5"/>
130
- </g>
131
- <g>
132
- <rect x="18.8" y="40" fill="none" stroke="#FFFFFF" stroke-miterlimit="10" width="14" height="38"/>
133
- <rect x="34.9" y="40" fill="none" stroke="#FFFFFF" stroke-miterlimit="10" width="14" height="38"/>
134
- <rect x="51.1" y="40" fill="none" stroke="#FFFFFF" stroke-miterlimit="10" width="14" height="38"/>
135
- <rect x="67.2" y="40" fill="none" stroke="#FFFFFF" stroke-miterlimit="10" width="14" height="38"/>
136
- </g>
137
- </g>
138
- </g>
139
- </svg>
140
- '
1
+ <%
2
+ init = <<~JAVASCRIPT
3
+ promethee.definitions.push({
4
+ name: 'Text',
5
+ icon: #{render('promethee/components/text/icon').to_json.html_safe},
6
+ data: {
7
+ type: 'text',
8
+ attributes: {
9
+ body: 'Edit me'
10
+ }
11
+ }
12
+ })
13
+ JAVASCRIPT
141
14
  %>
142
- <div ng-init="promethee.definitions.push({
143
- name: 'Text',
144
- icon: '<%= icon %>',
145
- data: {
146
- type: 'text',
147
- attributes: {
148
- body: 'Edit me'
149
- }
150
- }
151
- })"></div>
15
+
16
+ <%= content_tag :div, nil, 'ng-init': init %>
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100">
2
+ <path fill="#FFF" d="M38.8,40.8 C38.8,39.2 38.7,37.5 38.5,35.6 C40.8,35.7 44.6,35.7 50,35.7 C55.4,35.7 59.2,35.7 61.4,35.6 C61.2,37.5 61.1,39.3 61.1,40.8 C61.1,42.2 61.1,43.3 61.2,44.1 L60.3,44.1 C60.1,42 59.8,40.4 59.5,39.4 C59.2,38.4 58.6,37.6 57.8,37.2 C57,36.7 55.7,36.5 54.1,36.5 L51.9,36.5 L51.9,59.7 C51.9,60.8 52,61.7 52.2,62.2 C52.4,62.7 52.8,63.1 53.4,63.3 C54,63.5 54.8,63.6 56,63.7 L56,64.5 C54.6,64.4 52.6,64.4 50,64.4 C47.3,64.4 45.3,64.4 44,64.5 L44,63.7 C45.2,63.7 46.1,63.5 46.6,63.3 C47.2,63.1 47.5,62.7 47.8,62.2 C48,61.7 48.1,60.9 48.1,59.7 L48.1,36.5 L45.9,36.5 C44.2,36.5 43,36.7 42.2,37.2 C41.4,37.7 40.8,38.4 40.5,39.4 C40.2,40.4 39.9,42 39.7,44.1 L38.8,44.1 C38.8,43.3 38.8,42.2 38.8,40.8 Z M63.5,23 L63.5,31.4 L72.4,31.4 L72.4,33.4 L61.5,33.4 L61.5,23 L63.5,23 Z M63.8991213,22 L74.4,31.9705313 L74.4,78 L25.6,78 L25.6,22 L63.8991213,22 Z M63.1008787,24 L27.6,24 L27.6,76 L72.4,76 L72.4,32.8294687 L63.1008787,24 Z"/>
3
+ </svg>
@@ -1,31 +1,16 @@
1
- <%
2
- icon = '
3
- <?xml version="1.0" encoding="utf-8"?>
4
- <!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
5
- <svg version="1.1" id="Calque_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
6
- viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve">
7
- <rect x="18.9" y="28" fill="none" stroke="#FFFFFF" stroke-miterlimit="10" width="62.1" height="44"/>
8
- <g>
9
- <path fill="#FFFFFF" d="M84.5,25v50h-69V25H84.5 M86.5,23h-73v54h73V23L86.5,23z"/>
10
- </g>
11
- <g>
12
- <polygon fill="#FFFFFF" points="47.2,44.6 47.2,55.4 56.3,50 "/>
13
- <g>
14
- <path fill="#FFFFFF" d="M50,41.6c4.6,0,8.4,3.8,8.4,8.4s-3.8,8.4-8.4,8.4s-8.4-3.8-8.4-8.4S45.4,41.6,50,41.6 M50,40.6
15
- c-5.2,0-9.4,4.2-9.4,9.4s4.2,9.4,9.4,9.4c5.2,0,9.4-4.2,9.4-9.4S55.2,40.6,50,40.6L50,40.6z"/>
16
- </g>
17
- </g>
18
- </svg>
19
- '
1
+ <%
2
+ init = <<~JAVASCRIPT
3
+ promethee.definitions.push({
4
+ name: 'Video',
5
+ icon: #{render('promethee/components/video/icon').to_json.html_safe},
6
+ data: {
7
+ type: 'video',
8
+ attributes: {
9
+ url: 'https://vimeo.com/115082758'
10
+ }
11
+ }
12
+ })
13
+ JAVASCRIPT
20
14
  %>
21
15
 
22
- <div ng-init="promethee.definitions.push({
23
- name: 'Video',
24
- icon: '<%= icon %>',
25
- data: {
26
- type: 'video',
27
- attributes: {
28
- url: 'https://vimeo.com/115082758'
29
- }
30
- }
31
- })"></div>
16
+ <%= content_tag :div, nil, 'ng-init': init %>
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100">
2
+ <path fill="#FFF" d="M82,27.5 L82,72.5 L18.9,72.5 L18.9,27.5 L82,27.5 Z M19.9,28.5 L19.9,71.5 L81,71.5 L81,28.5 L19.9,28.5 Z M87,23 L87,77 L14,77 L14,23 L87,23 Z M85,25 L16,25 L16,75 L85,75 L85,25 Z M50.5,40.6 C45.3,40.6 41.1,44.8 41.1,50 C41.1,55.2 45.3,59.4 50.5,59.4 C55.7,59.4 59.9,55.2 59.9,50 C59.9,44.8 55.7,40.6 50.5,40.6 L50.5,40.6 Z M50.5,41.6 C55.1,41.6 58.9,45.4 58.9,50 C58.9,54.6 55.1,58.4 50.5,58.4 C45.9,58.4 42.1,54.6 42.1,50 C42.1,45.4 45.9,41.6 50.5,41.6 L50.5,41.6 Z M47.7,44.6 L47.7,55.4 L56.8,50 L47.7,44.6 Z"/>
3
+ </svg>
@@ -9,7 +9,7 @@ promethee
9
9
  revertDuration: 0,
10
10
  scroll: true,
11
11
  refreshPositions: true,
12
- cursor: 'move',
12
+ cursor: 'move',
13
13
  cursorAt: { top: 0, left: 0 },
14
14
  helper: 'clone',
15
15
  appendTo: '.promethee-edit__move',
@@ -34,7 +34,7 @@ promethee
34
34
  revertDuration: 0,
35
35
  scroll: true,
36
36
  refreshPositions: true,
37
- cursor: 'move',
37
+ cursor: 'move',
38
38
  start: function() {
39
39
  var $elementDragged = $(element[0]);
40
40
  var type = $elementDragged.data('type');
@@ -55,7 +55,7 @@ promethee
55
55
  }
56
56
  }
57
57
  })
58
- .directive('droppable', function($compile) {
58
+ .directive('droppable', ['$compile', 'presets', 'identifier', function($compile, presets, identifier) {
59
59
  return {
60
60
  restrict: 'A',
61
61
  link: function(scope, element, attrs) {
@@ -66,22 +66,39 @@ promethee
66
66
  var draggedFromList = angular.element(ui.draggable).parent().scope().components;
67
67
  var droppedToList = angular.element(this).scope().components;
68
68
  var droppedToIndex = parseInt(this.getAttribute('data-index'));
69
+ var draggedFromPresets = ui.draggable.attr('data-preset');
70
+
71
+ if(draggedFromPresets) {
72
+ var preset = presets.find(function(preset) {
73
+ return preset.name === draggedFromPresets;
74
+ });
75
+
76
+ var provideIdentifiers = function(components) {
77
+ var component;
78
+ for(var i = 0; i < components.length; i++) {
79
+ component = components[i];
80
+ component.id = identifier.generate();
81
+ if(Array.isArray(component.children)) provideIdentifiers(component.children);
82
+ }
83
+
84
+ return components;
85
+ };
86
+
87
+ var components = provideIdentifiers(angular.copy(preset.components));
88
+ droppedToList.splice.apply(droppedToList, [droppedToIndex, 0].concat(components));
89
+
90
+ scope.$apply();
91
+
92
+ return;
93
+ }
94
+
69
95
  if (draggedFromList === undefined) {
70
96
  draggedFromLibrary = true;
71
97
  }
72
98
  if (draggedFromLibrary) {
73
99
  var definition = angular.element(ui.draggable).scope().definition;
74
100
  var component = angular.copy(definition.data);
75
- // FIXME dirty
76
- function guid() {
77
- function s4() {
78
- return Math.floor((1 + Math.random()) * 0x10000)
79
- .toString(16)
80
- .substring(1);
81
- }
82
- return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
83
- }
84
- component.id = guid();
101
+ component.id = identifier.generate();
85
102
  } else {
86
103
  var draggedFromIndex = parseInt(ui.draggable[0].getAttribute('data-list-index'));
87
104
  // console.log('dragged', draggedFromList, draggedFromIndex);
@@ -104,10 +121,10 @@ promethee
104
121
  });
105
122
  }
106
123
  }
107
- });
124
+ }]);
108
125
 
109
- promethee.controller('AdderController',
110
- ['$scope', '$rootScope', 'definitions', 'identifier',
126
+ promethee.controller('AdderController',
127
+ ['$scope', '$rootScope', 'definitions', 'identifier',
111
128
  function($scope, $rootScope, definitions, identifier) {
112
129
 
113
130
  $scope.adding = false;
@@ -141,8 +158,8 @@ promethee.controller('AdderController',
141
158
  <div class="row">
142
159
  <div ng-repeat="definition in promethee.definitions"
143
160
  class="col-md-12 col-lg-6">
144
- <div addable
145
- class="promethee-edit__library__item"
161
+ <div addable
162
+ class="promethee-edit__library__item"
146
163
  data-type="{{definition.data.type}}">
147
164
  <div class="promethee-edit__library__item__icon" ng-bind-html="definition.icon | htmlSafe"></div>
148
165
  <div class="promethee-edit__library__item__name">{{definition.name}}</div>
@@ -152,6 +169,14 @@ promethee.controller('AdderController',
152
169
  </div>
153
170
  <div class="promethee-edit__library-header">Presets</div>
154
171
  <div class="promethee-edit__library-content">
172
+ <div class="row">
173
+ <div ng-repeat="preset in promethee.presets" class="col-md-12 col-lg-6">
174
+ <div addable class="promethee-edit__library__item" data-type="text" data-preset="{{preset.name}}">
175
+ <div class="promethee-edit__library__item__icon" ng-bind-html="preset.icon | htmlSafe"></div>
176
+ <div class="promethee-edit__library__item__name">{{preset.name}}</div>
177
+ </div>
178
+ </div>
179
+ </div>
155
180
  </div>
156
181
  </div>
157
182
 
@@ -175,8 +200,10 @@ promethee.controller('AdderController',
175
200
  {{promethee.inspected.type}}
176
201
  </div>
177
202
  <div class="promethee-edit__inspect-content">
178
- <ng-include ng-if="promethee.inspected"
179
- src="'promethee/components/' + promethee.inspected.type + '/edit/inspect'"></ng-include>
203
+ <div ng-repeat="definition in promethee.definitions">
204
+ <ng-include src="'promethee/components/' + definition.data.type + '/edit/inspect'"
205
+ ng-show="promethee.inspected.type == definition.data.type"></ng-include>
206
+ </div>
180
207
  </div>
181
208
  </div>
182
209
  </div>
@@ -189,7 +216,7 @@ promethee.controller('AdderController',
189
216
 
190
217
  <script type="text/ng-template" id="promethee/move/components">
191
218
  <div ng-init="parent_id = component.id; parent_type = component.type; components = component.children">
192
- <div
219
+ <div
193
220
  droppable
194
221
  class="<%= promethee_bem_classes 'promethee-edit__move__droppable', '--{{parent_type}}', '--first' %>"
195
222
  data-id="{{parent_id}}"
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100">
2
+ <path fill="#FFF" d="M46.629601,61.6851178 L46.629601,34.36 L16.3737374,34.36 L16.3737374,58.1295698 L23.8181881,48.8040935 L30.7098655,60.0075245 L38.9520095,54.8543739 L46.629601,61.6851178 Z M46.629601,63.5136154 L38.806792,56.5536716 L30.2628248,61.8955281 L23.671799,51.1808504 L16.3737374,60.3229489 L16.3737374,65.1949102 L46.629601,65.1949102 L46.629601,63.5136154 Z M15,33 L48.0033384,33 L48.0033384,66.5549102 L15,66.5549102 L15,33 Z M23.3795232,45.24 C21.2892432,45.24 19.5947365,43.5793834 19.5947365,41.5309091 C19.5947365,39.4824347 21.2892432,37.8218182 23.3795232,37.8218182 C25.4698031,37.8218182 27.1643098,39.4824347 27.1643098,41.5309091 C27.1643098,43.5793834 25.4698031,45.24 23.3795232,45.24 Z M23.3795232,43.88 C24.7142133,43.88 25.7905724,42.8251681 25.7905724,41.5309091 C25.7905724,40.2366501 24.7142133,39.1818182 23.3795232,39.1818182 C22.044833,39.1818182 20.9684739,40.2366501 20.9684739,41.5309091 C20.9684739,42.8251681 22.044833,43.88 23.3795232,43.88 Z M50.8598227,38.5 L50.8598227,37.5 L74.1669281,37.5 L74.1669281,38.5 L50.8598227,38.5 Z M50.8598227,42.5 L50.8598227,41.5 L84.393388,41.5 L84.393388,42.5 L50.8598227,42.5 Z M50.8598227,46.5 L50.8598227,45.5 L84.393388,45.5 L84.393388,46.5 L50.8598227,46.5 Z M50.8598227,50.5 L50.8598227,49.5 L78.3643678,49.5 L78.3643678,50.5 L50.8598227,50.5 Z M50.8598227,54.5 L50.8598227,53.5 L82.3598227,53.5 L82.3598227,54.5 L50.8598227,54.5 Z"/>
3
+ </svg>
@@ -0,0 +1,33 @@
1
+ <script>
2
+ angular.injector(['ng', 'Promethee']).get('presets').push({
3
+ name: 'Image with text',
4
+ icon: <%= render('promethee/presets/icon.image-with-text').to_json.html_safe %>,
5
+ components: [
6
+ {
7
+ "type": "row",
8
+ "children": [
9
+ {
10
+ "type": "column",
11
+ "attributes": {"size": 4, "offset": 0},
12
+ "children": [
13
+ {
14
+ "type": "image",
15
+ "attributes": {"src": "https://images.unsplash.com/photo-1502919280275-1bed9aca68ab?auto=format&fit=crop&w=1500&q=60&ixid=dW5zcGxhc2guY29tOzs7Ozs%3D"}
16
+ }
17
+ ]
18
+ },
19
+ {
20
+ "type": "column",
21
+ "attributes": {"size": 8, "offset": 0},
22
+ "children": [
23
+ {
24
+ "type": "text",
25
+ "attributes": {"body": "<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. A dicta, est quos distinctio culpa! Quasi cupiditate, totam nulla reprehenderit animi iusto qui cumque culpa repellat eum sit? Debitis, laboriosam reiciendis!</p>"}
26
+ }
27
+ ]
28
+ }
29
+ ]
30
+ }
31
+ ]
32
+ });
33
+ </script>