summaryrefslogtreecommitdiffstats
path: root/apps/workflowengine/js
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-07-28 11:44:22 +0200
committerJoas Schilling <coding@schilljs.com>2016-08-01 17:19:04 +0200
commit8a753342eed0ba1f47c0f6c6ead1d374489fbeef (patch)
tree726ed251a7493b28169e6d22e810f17353263cf2 /apps/workflowengine/js
parent136a1a42236f60276572a080e5510ec40c8e683f (diff)
downloadnextcloud-server-8a753342eed0ba1f47c0f6c6ead1d374489fbeef.tar.gz
nextcloud-server-8a753342eed0ba1f47c0f6c6ead1d374489fbeef.zip
Add file mime type
Diffstat (limited to 'apps/workflowengine/js')
-rw-r--r--apps/workflowengine/js/admin.js2
-rw-r--r--apps/workflowengine/js/filemimetypeplugin.js72
-rw-r--r--apps/workflowengine/js/filesizeplugin.js15
-rw-r--r--apps/workflowengine/js/filesystemtagsplugin.js4
-rw-r--r--apps/workflowengine/js/usergroupmembershipplugin.js4
5 files changed, 87 insertions, 10 deletions
diff --git a/apps/workflowengine/js/admin.js b/apps/workflowengine/js/admin.js
index e6df4b75f70..ce85c8c008b 100644
--- a/apps/workflowengine/js/admin.js
+++ b/apps/workflowengine/js/admin.js
@@ -296,7 +296,7 @@
_.each(OCA.WorkflowEngine.availablePlugins, function(plugin) {
if (_.isFunction(plugin.render)) {
- plugin.render(valueElement, check['class'], check['value']);
+ plugin.render(valueElement, check);
}
});
}, this);
diff --git a/apps/workflowengine/js/filemimetypeplugin.js b/apps/workflowengine/js/filemimetypeplugin.js
new file mode 100644
index 00000000000..33cbbd7fd7e
--- /dev/null
+++ b/apps/workflowengine/js/filemimetypeplugin.js
@@ -0,0 +1,72 @@
+/**
+ * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+(function() {
+
+ OCA.WorkflowEngine = OCA.WorkflowEngine || {};
+ OCA.WorkflowEngine.Plugins = OCA.WorkflowEngine.Plugins || {};
+
+ OCA.WorkflowEngine.Plugins.FileMimeTypePlugin = {
+ getCheck: function() {
+ return {
+ 'class': 'OCA\\WorkflowEngine\\Check\\FileMimeType',
+ 'name': t('workflowengine', 'File mime type (upload)'),
+ 'operators': [
+ {'operator': 'is', 'name': t('workflowengine', 'is')},
+ {'operator': '!is', 'name': t('workflowengine', 'is not')},
+ {'operator': 'matches', 'name': t('workflowengine', 'matches')},
+ {'operator': '!matches', 'name': t('workflowengine', 'does not match')}
+ ]
+ };
+ },
+ render: function(element, check) {
+ if (check['class'] !== 'OCA\\WorkflowEngine\\Check\\FileMimeType') {
+ return;
+ }
+
+ var placeholder = t('workflowengine', 'text/plain');
+ if (check['operator'] === 'matches' || check['operator'] === '!matches') {
+ placeholder = t('workflowengine', '/^text\\/(plain|html)$/i');
+
+ if (this._validateRegex(check['value'])) {
+ $(element).removeClass('invalid-input');
+ } else {
+ $(element).addClass('invalid-input');
+ }
+ }
+
+ $(element).css('width', '250px')
+ .attr('placeholder', placeholder)
+ .attr('title', t('workflowengine', 'Example: {placeholder}', {placeholder: placeholder}))
+ .addClass('has-tooltip')
+ .tooltip({
+ placement: 'bottom'
+ });
+ },
+
+ _validateRegex: function(string) {
+ var regexRegex = /^\/(.*)\/([gui]{0,3})$/,
+ result = regexRegex.exec(string);
+ return result !== null;
+ }
+ };
+})();
+
+OC.Plugins.register('OCA.WorkflowEngine.CheckPlugins', OCA.WorkflowEngine.Plugins.FileMimeTypePlugin);
diff --git a/apps/workflowengine/js/filesizeplugin.js b/apps/workflowengine/js/filesizeplugin.js
index add2e57821c..0efa9d00edf 100644
--- a/apps/workflowengine/js/filesizeplugin.js
+++ b/apps/workflowengine/js/filesizeplugin.js
@@ -27,7 +27,7 @@
getCheck: function() {
return {
'class': 'OCA\\WorkflowEngine\\Check\\FileSize',
- 'name': t('workflowengine', 'File size'),
+ 'name': t('workflowengine', 'File size (upload)'),
'operators': [
{'operator': 'less', 'name': t('workflowengine', 'less')},
{'operator': '!greater', 'name': t('workflowengine', 'less or equals')},
@@ -36,14 +36,19 @@
]
};
},
- render: function(element, classname, value) {
- if (classname !== 'OCA\\WorkflowEngine\\Check\\FileSize') {
+ render: function(element, check) {
+ if (check['class'] !== 'OCA\\WorkflowEngine\\Check\\FileSize') {
return;
}
+ var placeholder = '12 MB'; // Do not translate!!!
$(element).css('width', '250px')
- .attr('placeholder', t('workflowengine', '12 MB'))
- ;
+ .attr('placeholder', placeholder)
+ .attr('title', t('workflowengine', 'Example: {placeholder}', {placeholder: placeholder}))
+ .addClass('has-tooltip')
+ .tooltip({
+ placement: 'bottom'
+ });
}
};
})();
diff --git a/apps/workflowengine/js/filesystemtagsplugin.js b/apps/workflowengine/js/filesystemtagsplugin.js
index 6f2f231c5e7..026345571e7 100644
--- a/apps/workflowengine/js/filesystemtagsplugin.js
+++ b/apps/workflowengine/js/filesystemtagsplugin.js
@@ -41,8 +41,8 @@
]
};
},
- render: function(element, classname, value) {
- if (classname !== 'OCA\\WorkflowEngine\\Check\\FileSystemTags') {
+ render: function(element, check) {
+ if (check['class'] !== 'OCA\\WorkflowEngine\\Check\\FileSystemTags') {
return;
}
diff --git a/apps/workflowengine/js/usergroupmembershipplugin.js b/apps/workflowengine/js/usergroupmembershipplugin.js
index 528a7bd3e3d..1c09e7d5ccd 100644
--- a/apps/workflowengine/js/usergroupmembershipplugin.js
+++ b/apps/workflowengine/js/usergroupmembershipplugin.js
@@ -34,8 +34,8 @@
]
};
},
- render: function(element, classname, value) {
- if (classname !== 'OCA\\WorkflowEngine\\Check\\UserGroupMembership') {
+ render: function(element, check) {
+ if (check['class'] !== 'OCA\\WorkflowEngine\\Check\\UserGroupMembership') {
return;
}