fnp
/
fnpeditor.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
cff9718
)
validate cover extension in metadata dialog
author
Jan Szejko
<janek37@gmail.com>
Mon, 30 Jan 2017 13:50:13 +0000
(14:50 +0100)
committer
Jan Szejko
<janek37@gmail.com>
Mon, 30 Jan 2017 13:50:13 +0000
(14:50 +0100)
src/editor/plugins/core/metadataEditor/action.js
patch
|
blob
|
history
src/editor/plugins/core/metadataEditor/view.js
patch
|
blob
|
history
src/editor/views/dialog/dialog.html
patch
|
blob
|
history
src/editor/views/dialog/dialog.js
patch
|
blob
|
history
diff --git
a/src/editor/plugins/core/metadataEditor/action.js
b/src/editor/plugins/core/metadataEditor/action.js
index
cb3d605
..
96e5b95
100644
(file)
--- a/
src/editor/plugins/core/metadataEditor/action.js
+++ b/
src/editor/plugins/core/metadataEditor/action.js
@@
-21,12
+21,18
@@
return function(ctx) {
var dialog = Dialog.create({
title: gettext('Document Metadata'),
executeButtonText: gettext('Close'),
var dialog = Dialog.create({
title: gettext('Document Metadata'),
executeButtonText: gettext('Close'),
- cssClass: 'metadataEditor'
+ cssClass: 'metadataEditor',
+ closeButton: false
}),
view = new View(params.doc.root, ctx.config);
dialog.show();
dialog.setContentView(view.dom);
dialog.on('execute', function(e) {
}),
view = new View(params.doc.root, ctx.config);
dialog.show();
dialog.setContentView(view.dom);
dialog.on('execute', function(e) {
+ var cover_url = view.getMetadataByKey('relation.coverimage.url');
+ if (cover_url && !cover_url.match(/\.(png|jpg|jpeg|gif|tif|tiff)$/i)) {
+ window.alert(gettext('The cover needs to be an image file: jpg, png, gif. Use another URL or clear the cover field.'));
+ return;
+ }
e.success();
});
}
e.success();
});
}
diff --git
a/src/editor/plugins/core/metadataEditor/view.js
b/src/editor/plugins/core/metadataEditor/view.js
index
18434e5
..
cde4f89
100644
(file)
--- a/
src/editor/plugins/core/metadataEditor/view.js
+++ b/
src/editor/plugins/core/metadataEditor/view.js
@@
-128,6
+128,16
@@
_.extend(View.prototype, {
view.addMetadataRow(row);
});
},
view.addMetadataRow(row);
});
},
+ getMetadataByKey: function (key) {
+ var ret;
+ this.node.getMetadata().some(function (row) {
+ if (row.key == 'relation.coverimage.url') {
+ ret = row.value;
+ return true;
+ }
+ });
+ return ret;
+ },
addMetadataRow: function(row) {
console.log(row);
var newRow = $(_.template(itemTemplate)({key: row.getKey() || '', value: row.getValue() || ''}));
addMetadataRow: function(row) {
console.log(row);
var newRow = $(_.template(itemTemplate)({key: row.getKey() || '', value: row.getValue() || ''}));
diff --git
a/src/editor/views/dialog/dialog.html
b/src/editor/views/dialog/dialog.html
index
7499cd1
..
3e1463e
100644
(file)
--- a/
src/editor/views/dialog/dialog.html
+++ b/
src/editor/views/dialog/dialog.html
@@
-1,6
+1,6
@@
<div class="rng-dialog modal hide static <%= cssClass %>">
<div class="modal-header">
<div class="rng-dialog modal hide static <%= cssClass %>">
<div class="modal-header">
- <
button type="button" class="close">×</button
>
+ <
% if(closeButton) { %><button type="button" class="close">×</button><% } %
>
<h1><%= title %></h1>
</div>
<div class="modal-body">
<h1><%= title %></h1>
</div>
<div class="modal-body">
diff --git
a/src/editor/views/dialog/dialog.js
b/src/editor/views/dialog/dialog.js
index
7d9f775
..
642342d
100644
(file)
--- a/
src/editor/views/dialog/dialog.js
+++ b/
src/editor/views/dialog/dialog.js
@@
-29,7
+29,8
@@
define(function(require) {
this.setElement(this.template(_.extend({
executeButtonText: null,
cancelButtonText: null,
this.setElement(this.template(_.extend({
executeButtonText: null,
cancelButtonText: null,
- cssClass: ''
+ cssClass: '',
+ closeButton: true
}, this.options)));
var body = this.$('.modal-body');
}, this.options)));
var body = this.$('.modal-body');