promethee 1.6.10 → 1.6.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/promethee/_edit.html.erb +37 -27
- data/app/views/promethee/components/aside/_edit.define.html.erb +3 -3
- data/app/views/promethee/components/collection/_edit.define.html.erb +3 -3
- data/app/views/promethee/components/collection/_edit.inspect.html.erb +2 -2
- data/app/views/promethee/components/column/_edit.define.html.erb +4 -4
- data/app/views/promethee/components/column/_edit.move.html.erb +1 -1
- data/app/views/promethee/components/cover/_edit.define.html.erb +4 -4
- data/app/views/promethee/components/cover/_edit.inspect.html.erb +1 -9
- data/app/views/promethee/components/cover/_edit.move.html.erb +1 -3
- data/app/views/promethee/components/cover/_localize.html.erb +1 -1
- data/app/views/promethee/components/cover/_show.html.erb +3 -3
- data/app/views/promethee/components/image/_edit.define.html.erb +4 -4
- data/app/views/promethee/components/image/_edit.inspect.html.erb +2 -9
- data/app/views/promethee/components/image/_edit.move.html.erb +4 -8
- data/app/views/promethee/components/image/_localize.html.erb +1 -1
- data/app/views/promethee/components/image/_show.html.erb +3 -3
- data/app/views/promethee/components/page/_edit.define.html.erb +21 -0
- data/app/views/promethee/components/page/_icon.svg +2 -0
- data/app/views/promethee/components/row/_edit.define.html.erb +12 -4
- data/app/views/promethee/components/row/_edit.inspect.html.erb +7 -1
- data/app/views/promethee/components/row/_edit.move.html.erb +1 -1
- data/app/views/promethee/components/slider/_edit.define.html.erb +3 -3
- data/app/views/promethee/components/slider/_edit.inspect.html.erb +2 -2
- data/app/views/promethee/components/text/_edit.define.html.erb +3 -3
- data/app/views/promethee/components/video/_edit.define.html.erb +3 -3
- data/app/views/promethee/edit/_move.html.erb +4 -5
- data/app/views/promethee/templates/_uploader.html.erb +51 -0
- data/lib/promethee/rails/helper.rb +4 -0
- data/lib/promethee/rails/version.rb +1 -1
- metadata +6 -4
- data/app/views/promethee/utils/_identifier.html.erb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ccb914975b52c26fdab25010930c298bde59c98
|
4
|
+
data.tar.gz: facb91d0c73e987d34392813ff2a6e38e166e001
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8239f1b92dc3aab19341ec7c119201465c5c710453c570fe0921498a159fcb95e796b1ec2005eece167b8ccf7d72898e59474fe6cd255ccb99488872baf1e17b
|
7
|
+
data.tar.gz: 7d3c31e91b58d159bbda3d20f32cf1b80cf5ef953a6203198f93fd197e3eaef8880f9a3fac0ea48daa6558a11f7dafc52f11f683252b82bd4cae2f0f71599dc1
|
@@ -22,15 +22,25 @@ var promethee = angular
|
|
22
22
|
<% end %>
|
23
23
|
|
24
24
|
<script type="text/javascript">
|
25
|
-
promethee.controller('PrometheeController', ['$scope', 'summernoteConfig', 'presets', '
|
25
|
+
promethee.controller('PrometheeController', ['$scope', 'summernoteConfig', 'presets', '$filter', function($scope, summernoteConfig, presets, $filter) {
|
26
|
+
|
27
|
+
$scope.generateIdentifier = function() {
|
28
|
+
// https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
|
29
|
+
function s4() {
|
30
|
+
return Math.floor((1 + Math.random()) * 0x10000)
|
31
|
+
.toString(16)
|
32
|
+
.substring(1);
|
33
|
+
}
|
34
|
+
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
35
|
+
}
|
36
|
+
|
26
37
|
$scope.data = <%= promethee_data.to_json.html_safe %>;
|
27
38
|
|
28
|
-
// Data (TODO use
|
39
|
+
// Data (TODO use standard method createComponentFromDefinition)
|
29
40
|
if (typeof $scope.data !== 'object' || $scope.data === null || $scope.data.type !== 'page') {
|
30
41
|
$scope.data = {
|
31
|
-
id:
|
42
|
+
id: $scope.generateIdentifier(),
|
32
43
|
type: 'page',
|
33
|
-
version: 1,
|
34
44
|
attributes: {
|
35
45
|
title: 'New page',
|
36
46
|
description: '',
|
@@ -41,8 +51,6 @@ promethee.controller('PrometheeController', ['$scope', 'summernoteConfig', 'pres
|
|
41
51
|
};
|
42
52
|
}
|
43
53
|
|
44
|
-
$scope.identifier = identifier;
|
45
|
-
|
46
54
|
$scope.promethee = {
|
47
55
|
data: $scope.data,
|
48
56
|
definitions: [],
|
@@ -53,30 +61,29 @@ promethee.controller('PrometheeController', ['$scope', 'summernoteConfig', 'pres
|
|
53
61
|
fullscreen: true
|
54
62
|
};
|
55
63
|
|
56
|
-
$scope.
|
57
|
-
|
58
|
-
|
59
|
-
|
64
|
+
$scope.findDefinitionByType = function(type) {
|
65
|
+
return $filter('filter')($scope.promethee.definitions, {'data':{'type':type}})[0];
|
66
|
+
}
|
67
|
+
|
68
|
+
$scope.addComponentByType = function(type, target, index = -1) {
|
69
|
+
var definition = $scope.findDefinitionByType(type);
|
70
|
+
$scope.addComponent(definition, target, index);
|
71
|
+
}
|
60
72
|
|
61
|
-
|
62
|
-
|
73
|
+
$scope.addComponent = function(definition, target, index = -1) {
|
74
|
+
var component = $scope.createComponentFromDefinition(definition);
|
75
|
+
if (index === -1) {
|
76
|
+
target.push(component);
|
77
|
+
} else {
|
78
|
+
target.splice(index, 0, component);
|
63
79
|
}
|
80
|
+
}
|
64
81
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
}).then(function (resp) {
|
71
|
-
store.blob = resp.data;
|
72
|
-
$scope.upload_error = undefined;
|
73
|
-
}, function (resp) {
|
74
|
-
$scope.upload_error = "An error occured (error " + resp.status + ": " + resp.statusText + ")";
|
75
|
-
}, function (evt) {
|
76
|
-
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
|
77
|
-
$scope.upload_progress = progressPercentage;
|
78
|
-
});
|
79
|
-
};
|
82
|
+
$scope.createComponentFromDefinition = function(definition) {
|
83
|
+
var component = angular.copy(definition.data);
|
84
|
+
component.id = $scope.generateIdentifier();
|
85
|
+
return component;
|
86
|
+
}
|
80
87
|
|
81
88
|
$scope.inspect = function(component, event) {
|
82
89
|
if(event.target.closest('.promethee-edit__component') === event.currentTarget) {
|
@@ -162,6 +169,9 @@ promethee.controller('PrometheeController', ['$scope', 'summernoteConfig', 'pres
|
|
162
169
|
|
163
170
|
<div class="promethee-edit" ng-show="promethee.fullscreen">
|
164
171
|
<input type="hidden" name="page[data]" id="page_data" value="{{promethee.data}}" />
|
172
|
+
<div class="upload__modal" ng-show="upload.running">
|
173
|
+
|
174
|
+
</div>
|
165
175
|
<nav class="navbar navbar-default promethee-edit__navbar" ng-class="{'navbar-fixed-top': promethee.fullscreen }">
|
166
176
|
<div class="container-fluid">
|
167
177
|
<div class="navbar-header promethee-edit__icon">
|
@@ -2,8 +2,9 @@
|
|
2
2
|
init = <<~JAVASCRIPT
|
3
3
|
promethee.definitions.push({
|
4
4
|
name: 'Aside',
|
5
|
-
icon: #{
|
5
|
+
icon: #{ promethee_component_render_icon 'aside' },
|
6
6
|
position: 30,
|
7
|
+
library: true,
|
7
8
|
data: {
|
8
9
|
type: 'aside',
|
9
10
|
attributes: {
|
@@ -16,5 +17,4 @@
|
|
16
17
|
})
|
17
18
|
JAVASCRIPT
|
18
19
|
%>
|
19
|
-
|
20
|
-
<%= content_tag :div, nil, 'ng-init': init %>
|
20
|
+
<div ng-init="<%= init %>"></div>
|
@@ -2,8 +2,9 @@
|
|
2
2
|
init = <<~JAVASCRIPT
|
3
3
|
promethee.definitions.push({
|
4
4
|
name: 'Collection',
|
5
|
-
icon: #{
|
5
|
+
icon: #{ promethee_component_render_icon 'collection' },
|
6
6
|
position: 20,
|
7
|
+
library: true,
|
7
8
|
data: {
|
8
9
|
type: 'collection',
|
9
10
|
attributes: {
|
@@ -14,5 +15,4 @@
|
|
14
15
|
})
|
15
16
|
JAVASCRIPT
|
16
17
|
%>
|
17
|
-
|
18
|
-
<%= content_tag :div, nil, 'ng-init': init %>
|
18
|
+
<div ng-init="<%= init %>"></div>
|
@@ -30,7 +30,7 @@
|
|
30
30
|
</script>
|
31
31
|
|
32
32
|
<script>
|
33
|
-
promethee.controller('CollectionInspectorController', ['$scope',
|
33
|
+
promethee.controller('CollectionInspectorController', ['$scope', function($scope) {
|
34
34
|
var availableComponents = ['image', 'video'];
|
35
35
|
|
36
36
|
$scope.itemDefinitions = $scope.promethee.definitions.filter(function(definition) {
|
@@ -43,7 +43,7 @@
|
|
43
43
|
|
44
44
|
$scope.addItem = function(definition) {
|
45
45
|
var item = JSON.parse(JSON.stringify(definition.data));
|
46
|
-
item.id =
|
46
|
+
item.id = $scope.generateIdentifier();
|
47
47
|
|
48
48
|
$scope.promethee.inspected.children.push(item);
|
49
49
|
}
|
@@ -2,8 +2,9 @@
|
|
2
2
|
init = <<~JAVASCRIPT
|
3
3
|
promethee.definitions.push({
|
4
4
|
name: 'Column',
|
5
|
-
icon: #{
|
6
|
-
position:
|
5
|
+
icon: #{ promethee_component_render_icon 'column' },
|
6
|
+
position: 0,
|
7
|
+
library: false,
|
7
8
|
data: {
|
8
9
|
type: 'column',
|
9
10
|
attributes: {
|
@@ -15,5 +16,4 @@
|
|
15
16
|
})
|
16
17
|
JAVASCRIPT
|
17
18
|
%>
|
18
|
-
|
19
|
-
<%= content_tag :div, nil, 'ng-init': init %>
|
19
|
+
<div ng-init="<%= init %>"></div>
|
@@ -7,7 +7,7 @@
|
|
7
7
|
col-md-offset-{{component.attributes.offset}}">
|
8
8
|
<div class="promethee-edit__component__inner">
|
9
9
|
<%= render 'promethee/edit/move.remove' %>
|
10
|
-
<div class="header">Column</div>
|
10
|
+
<div class="header">Column {{$index + 1}}</div>
|
11
11
|
<ng-include src="'promethee/move/components'"></ng-include>
|
12
12
|
<pre class="hidden">{{component.attributes.search = concatenateChildrenSearch(component)}}</pre>
|
13
13
|
<div
|
@@ -2,12 +2,13 @@
|
|
2
2
|
init = <<~JAVASCRIPT
|
3
3
|
promethee.definitions.push({
|
4
4
|
name: 'Cover',
|
5
|
-
icon: #{
|
5
|
+
icon: #{ promethee_component_render_icon 'cover' },
|
6
6
|
position: 10,
|
7
|
+
library: true,
|
7
8
|
data: {
|
8
9
|
type: 'cover',
|
9
10
|
attributes: {
|
10
|
-
|
11
|
+
image: {
|
11
12
|
id: undefined,
|
12
13
|
name: ''
|
13
14
|
},
|
@@ -19,5 +20,4 @@
|
|
19
20
|
})
|
20
21
|
JAVASCRIPT
|
21
22
|
%>
|
22
|
-
|
23
|
-
<%= content_tag :div, nil, 'ng-init': init %>
|
23
|
+
<div ng-init="<%= init %>"></div>
|
@@ -1,13 +1,5 @@
|
|
1
1
|
<script type="text/ng-template" id="promethee/components/cover/edit/inspect">
|
2
|
-
<
|
3
|
-
<label class="label-control">Image</label>
|
4
|
-
<p>{{promethee.inspected.attributes.blob.name}}</p>
|
5
|
-
<div class="button btn btn-default" ngf-select="upload($file, promethee.inspected)" ngf-accept="'.jpg,.jpeg,.png,.gif'" class="drop-box">Select an image</div>
|
6
|
-
<div class="progress" ng-show="upload_progress != undefined && upload_progress != 0 && upload_progress != 100">
|
7
|
-
<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: {{upload_progress}}%"></div>
|
8
|
-
</div>
|
9
|
-
<div class="alert alert-danger" ng-show="upload_error">{{upload_error}}</div>
|
10
|
-
</div>
|
2
|
+
<promethee-uploader ng-model="promethee.inspected.attributes.image" label="Image" limits="'.jpg,.jpeg,.png,.gif'"></promethee-uploader>
|
11
3
|
|
12
4
|
<div class="form-group">
|
13
5
|
<label class="label-control">Surtitle</label>
|
@@ -2,9 +2,7 @@
|
|
2
2
|
<%= render 'promethee/edit/move.header', type: 'cover' %>
|
3
3
|
<div class=" promethee-edit__wrapper
|
4
4
|
promethee-edit__cover-content"
|
5
|
-
|
6
|
-
ngf-pattern="'.jpg,.jpeg,.png,.gif'"
|
7
|
-
style="background-image:url('{{ component.attributes.blob.id ? '/promethee/blob/' + component.attributes.blob.id : '' }}')">
|
5
|
+
style="background-image:url('{{ component.attributes.image.id ? '/promethee/blob/' + component.attributes.image.id : '' }}')">
|
8
6
|
<hgroup>
|
9
7
|
<h2 class="surtitle">{{component.attributes.surtitle}}</h2>
|
10
8
|
<h1>{{component.attributes.title}}</h1>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%
|
2
|
-
|
3
|
-
if
|
4
|
-
blob = ActiveStorage::Blob.find
|
2
|
+
image_data = component[:attributes][:image]
|
3
|
+
if image_data && image_data[:id]
|
4
|
+
blob = ActiveStorage::Blob.find image_data[:id]
|
5
5
|
end
|
6
6
|
|
7
7
|
surtitle = component[:attributes][:surtitle].to_s
|
@@ -2,12 +2,13 @@
|
|
2
2
|
init = <<~JAVASCRIPT
|
3
3
|
promethee.definitions.push({
|
4
4
|
name: 'Image',
|
5
|
-
icon: #{
|
5
|
+
icon: #{ promethee_component_render_icon 'image' },
|
6
6
|
position: 2,
|
7
|
+
library: true,
|
7
8
|
data: {
|
8
9
|
type: 'image',
|
9
10
|
attributes: {
|
10
|
-
|
11
|
+
image: {
|
11
12
|
id: undefined,
|
12
13
|
name: ''
|
13
14
|
},
|
@@ -18,5 +19,4 @@
|
|
18
19
|
})
|
19
20
|
JAVASCRIPT
|
20
21
|
%>
|
21
|
-
|
22
|
-
<%= content_tag :div, nil, 'ng-init': init %>
|
22
|
+
<div ng-init="<%= init %>"></div>
|
@@ -1,13 +1,6 @@
|
|
1
1
|
<script type="text/ng-template" id="promethee/components/image/edit/inspect">
|
2
|
-
|
3
|
-
|
4
|
-
<p>{{promethee.inspected.attributes.blob.name}}</p>
|
5
|
-
<div class="button btn btn-default" ngf-select="upload($file, promethee.inspected)" ngf-accept="'.jpg,.jpeg,.png,.gif'" class="drop-box">Select an image</div>
|
6
|
-
<div class="progress" ng-show="upload_progress != undefined && upload_progress != 0 && upload_progress != 100">
|
7
|
-
<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: {{upload_progress}}%"></div>
|
8
|
-
</div>
|
9
|
-
<div class="alert alert-danger" ng-show="upload_error">{{upload_error}}</div>
|
10
|
-
</div>
|
2
|
+
|
3
|
+
<promethee-uploader ng-model="promethee.inspected.attributes.image" label="Image" limits="'.jpg,.jpeg,.png,.gif'"></promethee-uploader>
|
11
4
|
|
12
5
|
<div class="form-group">
|
13
6
|
<label class="label-control">Caption</label>
|
@@ -1,17 +1,13 @@
|
|
1
1
|
<script type="text/ng-template" id="promethee/components/image/edit/move">
|
2
2
|
<%= render 'promethee/edit/move.header', type: 'image' %>
|
3
|
-
<figure ng-show="component.attributes.
|
4
|
-
<img ng-src="/promethee/blob/{{component.attributes.
|
5
|
-
ngf-drop="upload($file, component)"
|
6
|
-
ngf-pattern="'.jpg,.jpeg,.png,.gif'"
|
3
|
+
<figure ng-show="component.attributes.image.id">
|
4
|
+
<img ng-src="/promethee/blob/{{component.attributes.image.id}}"
|
7
5
|
class="img-responsive">
|
8
6
|
<figcaption ng-show="component.attributes.caption">{{component.attributes.caption}}</figcaption>
|
9
7
|
</figure>
|
10
|
-
<div ng-hide="component.attributes.
|
8
|
+
<div ng-hide="component.attributes.image.id">
|
11
9
|
<p ng-hide="editing"
|
12
|
-
|
13
|
-
ngf-pattern="'.jpg,.jpeg,.png,.gif'"
|
14
|
-
class="text-center text-empty">Click or drop file to set the image</p>
|
10
|
+
class="text-center text-empty">Click to set the image</p>
|
15
11
|
</div>
|
16
12
|
<pre class="hidden">{{component.attributes.search = (component.attributes.caption + ' ' + component.attributes.alt)}}</pre>
|
17
13
|
</div>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%
|
2
|
-
|
3
|
-
if
|
4
|
-
blob = ActiveStorage::Blob.find
|
2
|
+
image_data = component[:attributes][:image]
|
3
|
+
if image_data && image_data[:id]
|
4
|
+
blob = ActiveStorage::Blob.find image_data[:id]
|
5
5
|
end
|
6
6
|
|
7
7
|
alt = component[:attributes][:alt]
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%
|
2
|
+
init = <<~JAVASCRIPT
|
3
|
+
promethee.definitions.push({
|
4
|
+
name: 'Page',
|
5
|
+
icon: #{ promethee_component_render_icon 'page' },
|
6
|
+
position: 0,
|
7
|
+
library: false,
|
8
|
+
data: {
|
9
|
+
type: 'page',
|
10
|
+
attributes: {
|
11
|
+
title: 'New page',
|
12
|
+
description: '',
|
13
|
+
stylesheets: '',
|
14
|
+
javascripts: ''
|
15
|
+
},
|
16
|
+
children: []
|
17
|
+
}
|
18
|
+
})
|
19
|
+
JAVASCRIPT
|
20
|
+
%>
|
21
|
+
<div ng-init="<%= init %>"></div>
|
@@ -2,17 +2,25 @@
|
|
2
2
|
init = <<~JAVASCRIPT
|
3
3
|
promethee.definitions.push({
|
4
4
|
name: 'Row',
|
5
|
-
icon: #{
|
5
|
+
icon: #{ promethee_component_render_icon 'row' },
|
6
6
|
position: -2,
|
7
|
+
library: true,
|
7
8
|
data: {
|
8
9
|
type: 'row',
|
9
10
|
attributes: {
|
10
|
-
bgcolor: "transparent"
|
11
|
+
bgcolor: "transparent",
|
12
|
+
bgimage1: {
|
13
|
+
id: undefined,
|
14
|
+
name: ''
|
15
|
+
},
|
16
|
+
bgimage2: {
|
17
|
+
id: undefined,
|
18
|
+
name: ''
|
19
|
+
},
|
11
20
|
},
|
12
21
|
children: []
|
13
22
|
}
|
14
23
|
})
|
15
24
|
JAVASCRIPT
|
16
25
|
%>
|
17
|
-
|
18
|
-
<%= content_tag :div, nil, 'ng-init': init %>
|
26
|
+
<div ng-init="<%= init %>"></div>
|
@@ -1,6 +1,9 @@
|
|
1
1
|
<script type="text/ng-template" id="promethee/components/row/edit/inspect">
|
2
2
|
<div class="form-group">
|
3
|
-
|
3
|
+
<div class="btn btn-default" ng-click="addComponentByType('column', promethee.inspected.children)">Add column</div>
|
4
|
+
<ul class="list-unstyled">
|
5
|
+
<li ng-repeat="column in promethee.inspected.children">Column {{$index + 1}}</li>
|
6
|
+
</ul>
|
4
7
|
</div>
|
5
8
|
|
6
9
|
<div class="panel panel-default" ng-init="advancedConfigurationOpen = false">
|
@@ -14,5 +17,8 @@
|
|
14
17
|
<input ng-model="promethee.inspected.attributes.bgcolor" colorpicker="rgba" class="form-control" type="text" />
|
15
18
|
</div>
|
16
19
|
|
20
|
+
<promethee-uploader ng-model="promethee.inspected.attributes.bgimage1" label="Background Image 1" limits="'.jpg,.jpeg,.png,.gif'"></promethee-uploader>
|
21
|
+
<promethee-uploader ng-model="promethee.inspected.attributes.bgimage2" label="Background Image 2"></promethee-uploader>
|
22
|
+
|
17
23
|
</div>
|
18
24
|
</script>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<script type="text/ng-template" id="promethee/components/row/edit/move">
|
2
2
|
<%= render 'promethee/edit/move.header', type: 'row' %>
|
3
3
|
<div class="header">Row</div>
|
4
|
-
<div class="row">
|
4
|
+
<div class="row" style="background-image:url('{{ component.attributes.blob.id ? '/promethee/blob/' + component.attributes.blob.id : '' }}')">
|
5
5
|
<ng-include src="'promethee/move/components'"></ng-include>
|
6
6
|
<pre class="hidden">{{component.attributes.search = concatenateChildrenSearch(component)}}</pre>
|
7
7
|
</div>
|
@@ -2,8 +2,9 @@
|
|
2
2
|
init = <<~JAVASCRIPT
|
3
3
|
promethee.definitions.push({
|
4
4
|
name: 'Slider',
|
5
|
-
icon: #{
|
5
|
+
icon: #{ promethee_component_render_icon 'slider' },
|
6
6
|
position: 15,
|
7
|
+
library: true,
|
7
8
|
data: {
|
8
9
|
type: 'slider',
|
9
10
|
attributes: {
|
@@ -14,5 +15,4 @@
|
|
14
15
|
})
|
15
16
|
JAVASCRIPT
|
16
17
|
%>
|
17
|
-
|
18
|
-
<%= content_tag :div, nil, 'ng-init': init %>
|
18
|
+
<div ng-init="<%= init %>"></div>
|
@@ -33,7 +33,7 @@
|
|
33
33
|
</script>
|
34
34
|
|
35
35
|
<script>
|
36
|
-
promethee.controller('SliderInspectorController', ['$scope',
|
36
|
+
promethee.controller('SliderInspectorController', ['$scope', function($scope) {
|
37
37
|
var availableComponents = ['image', 'video'];
|
38
38
|
|
39
39
|
$scope.itemDefinitions = $scope.promethee.definitions.filter(function(definition) {
|
@@ -46,7 +46,7 @@
|
|
46
46
|
|
47
47
|
$scope.addItem = function(definition) {
|
48
48
|
var item = JSON.parse(JSON.stringify(definition.data));
|
49
|
-
item.id =
|
49
|
+
item.id = $scope.generateIdentifier();
|
50
50
|
|
51
51
|
$scope.promethee.inspected.children.push(item);
|
52
52
|
}
|
@@ -2,8 +2,9 @@
|
|
2
2
|
init = <<~JAVASCRIPT
|
3
3
|
promethee.definitions.push({
|
4
4
|
name: 'Text',
|
5
|
-
icon: #{
|
5
|
+
icon: #{ promethee_component_render_icon 'text' },
|
6
6
|
position: 1,
|
7
|
+
library: true,
|
7
8
|
data: {
|
8
9
|
type: 'text',
|
9
10
|
attributes: {
|
@@ -13,5 +14,4 @@
|
|
13
14
|
})
|
14
15
|
JAVASCRIPT
|
15
16
|
%>
|
16
|
-
|
17
|
-
<%= content_tag :div, nil, 'ng-init': init %>
|
17
|
+
<div ng-init="<%= init %>"></div>
|
@@ -2,8 +2,9 @@
|
|
2
2
|
init = <<~JAVASCRIPT
|
3
3
|
promethee.definitions.push({
|
4
4
|
name: 'Video',
|
5
|
-
icon: #{
|
5
|
+
icon: #{ promethee_component_render_icon 'video' },
|
6
6
|
position: 3,
|
7
|
+
library: true,
|
7
8
|
data: {
|
8
9
|
type: 'video',
|
9
10
|
attributes: {
|
@@ -13,5 +14,4 @@
|
|
13
14
|
})
|
14
15
|
JAVASCRIPT
|
15
16
|
%>
|
16
|
-
|
17
|
-
<%= content_tag :div, nil, 'ng-init': init %>
|
17
|
+
<div ng-init="<%= init %>"></div>
|
@@ -57,7 +57,7 @@ promethee
|
|
57
57
|
}
|
58
58
|
}
|
59
59
|
})
|
60
|
-
.directive('droppable', ['$compile', 'presets',
|
60
|
+
.directive('droppable', ['$compile', 'presets', function($compile, presets) {
|
61
61
|
return {
|
62
62
|
restrict: 'A',
|
63
63
|
link: function(scope, element, attrs) {
|
@@ -79,7 +79,7 @@ promethee
|
|
79
79
|
var component;
|
80
80
|
for(var i = 0; i < components.length; i++) {
|
81
81
|
component = components[i];
|
82
|
-
component.id =
|
82
|
+
component.id = scope.generateIdentifier();
|
83
83
|
if(Array.isArray(component.children)) provideIdentifiers(component.children);
|
84
84
|
}
|
85
85
|
|
@@ -100,7 +100,7 @@ promethee
|
|
100
100
|
if (draggedFromLibrary) {
|
101
101
|
var definition = angular.element(ui.draggable).scope().definition;
|
102
102
|
var component = angular.copy(definition.data);
|
103
|
-
component.id =
|
103
|
+
component.id = scope.generateIdentifier();
|
104
104
|
} else {
|
105
105
|
var draggedFromIndex = parseInt(ui.draggable[0].getAttribute('data-list-index'));
|
106
106
|
// console.log('dragged', draggedFromList, draggedFromIndex);
|
@@ -134,7 +134,7 @@ promethee
|
|
134
134
|
<div class="promethee-edit__library-header">Library</div>
|
135
135
|
<div class="promethee-edit__library-content">
|
136
136
|
<div class="row">
|
137
|
-
<div ng-repeat="definition in promethee.definitions | orderBy:'position'"
|
137
|
+
<div ng-repeat="definition in promethee.definitions | filter:{library:true} | orderBy:'position'"
|
138
138
|
class="col-md-12 col-lg-6">
|
139
139
|
<div addable
|
140
140
|
class="promethee-edit__library__item"
|
@@ -167,7 +167,6 @@ promethee
|
|
167
167
|
{{promethee.inspected.type}}
|
168
168
|
</div>
|
169
169
|
<div class="promethee-edit__inspect-content">
|
170
|
-
<ng-include src="'promethee/components/page/edit/inspect'" ng-show="promethee.inspected.type == 'page'"></ng-include>
|
171
170
|
<div ng-repeat="definition in promethee.definitions | orderBy:'position'">
|
172
171
|
<ng-include src="'promethee/components/' + definition.data.type + '/edit/inspect'"
|
173
172
|
ng-show="promethee.inspected.type == definition.data.type"></ng-include>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<script type="text/ng-template" id="promethee_uploader">
|
2
|
+
<div class="form-group" ngf-drop="prometheeUploader.upload($file)" ngf-pattern="{{limits || ''}}">
|
3
|
+
<label class="label-control">{{label}}</label>
|
4
|
+
<p>{{ngModel.name}}</p>
|
5
|
+
<div class="button btn btn-default" ngf-select="prometheeUploader.upload($file, ngModel)" ngf-accept="{{limits || ''}}" class="drop-box">Select an image</div>
|
6
|
+
<div class="progress" ng-show="prometheeUploader.upload_progress != undefined && prometheeUploader.upload_progress != 0 && prometheeUploader.upload_progress != 100">
|
7
|
+
<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: {{prometheeUploader.upload_progress}}%"></div>
|
8
|
+
</div>
|
9
|
+
<div class="alert alert-danger" ng-show="upload_error">{{upload_error}}</div>
|
10
|
+
</div>
|
11
|
+
</script>
|
12
|
+
|
13
|
+
<script>
|
14
|
+
promethee.directive('prometheeUploader', ['Upload', function(Upload) {
|
15
|
+
return {
|
16
|
+
restrict: 'E',
|
17
|
+
scope: {
|
18
|
+
ngModel: '=',
|
19
|
+
label: '@',
|
20
|
+
limits: '@',
|
21
|
+
},
|
22
|
+
templateUrl: 'promethee_uploader',
|
23
|
+
controller: function($scope) {
|
24
|
+
var self = this;
|
25
|
+
this.upload_error = '';
|
26
|
+
this.upload_progress = 0;
|
27
|
+
|
28
|
+
this.upload = function (file) {
|
29
|
+
if (file == undefined) return;
|
30
|
+
Upload.upload({
|
31
|
+
url: '<%= promethee_active_storage_create_path %>',
|
32
|
+
data: { file: file },
|
33
|
+
headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }
|
34
|
+
}).then(function (resp) {
|
35
|
+
$scope.ngModel = resp.data;
|
36
|
+
self.upload_error = undefined;
|
37
|
+
self.upload_error = "une erreur grave !";
|
38
|
+
}, function (resp) {
|
39
|
+
self.upload_error = "An error occured (error " + resp.status + ": " + resp.statusText + ")";
|
40
|
+
}, function (evt) {
|
41
|
+
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
|
42
|
+
self.upload_progress = progressPercentage;
|
43
|
+
});
|
44
|
+
};
|
45
|
+
|
46
|
+
},
|
47
|
+
controllerAs: 'prometheeUploader'
|
48
|
+
}
|
49
|
+
}]);
|
50
|
+
|
51
|
+
</script>
|
@@ -18,6 +18,10 @@ module Promethee::Rails::Helper
|
|
18
18
|
promethee_partials_for 'components/*/_edit.*.html.erb'
|
19
19
|
end
|
20
20
|
|
21
|
+
def promethee_component_render_icon(icon)
|
22
|
+
render("promethee/components/#{icon}/icon.svg").to_json.html_safe
|
23
|
+
end
|
24
|
+
|
21
25
|
def promethee_util_partials
|
22
26
|
promethee_partials_for 'utils/_*.html.erb'
|
23
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: promethee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Dargelos
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2018-06-
|
16
|
+
date: 2018-06-12 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: rails
|
@@ -214,8 +214,10 @@ files:
|
|
214
214
|
- app/views/promethee/components/image/_icon.svg
|
215
215
|
- app/views/promethee/components/image/_localize.html.erb
|
216
216
|
- app/views/promethee/components/image/_show.html.erb
|
217
|
+
- app/views/promethee/components/page/_edit.define.html.erb
|
217
218
|
- app/views/promethee/components/page/_edit.inspect.html.erb
|
218
219
|
- app/views/promethee/components/page/_edit.move.html.erb
|
220
|
+
- app/views/promethee/components/page/_icon.svg
|
219
221
|
- app/views/promethee/components/page/_localize.html.erb
|
220
222
|
- app/views/promethee/components/page/_show.html.erb
|
221
223
|
- app/views/promethee/components/row/_edit.define.html.erb
|
@@ -251,9 +253,9 @@ files:
|
|
251
253
|
- app/views/promethee/preview.html.erb
|
252
254
|
- app/views/promethee/show/_component.html.erb
|
253
255
|
- app/views/promethee/show/_components.html.erb
|
256
|
+
- app/views/promethee/templates/_uploader.html.erb
|
254
257
|
- app/views/promethee/utils/_html-safe.html.erb
|
255
258
|
- app/views/promethee/utils/_humanize.html.erb
|
256
|
-
- app/views/promethee/utils/_identifier.html.erb
|
257
259
|
- app/views/promethee/utils/_number-of-characters.html.erb
|
258
260
|
- app/views/promethee/utils/_number-of-words.html.erb
|
259
261
|
- app/views/promethee/utils/_summernote-config.html.erb
|
@@ -378,7 +380,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
378
380
|
version: '0'
|
379
381
|
requirements: []
|
380
382
|
rubyforge_project:
|
381
|
-
rubygems_version: 2.6.
|
383
|
+
rubygems_version: 2.6.13
|
382
384
|
signing_key:
|
383
385
|
specification_version: 4
|
384
386
|
summary: Bring fire to your page
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<script>
|
2
|
-
// Why doesn't this method just live in the adder controller ?
|
3
|
-
// Because the row component also need a special access to it in order to create cols with an id. So we make it global to the application.
|
4
|
-
promethee.provider('identifier', function() {
|
5
|
-
this.$get = function() {
|
6
|
-
return {
|
7
|
-
generate: function() {
|
8
|
-
// https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
|
9
|
-
function s4() {
|
10
|
-
return Math.floor((1 + Math.random()) * 0x10000)
|
11
|
-
.toString(16)
|
12
|
-
.substring(1);
|
13
|
-
}
|
14
|
-
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
15
|
-
}
|
16
|
-
};
|
17
|
-
};
|
18
|
-
});
|
19
|
-
</script>
|