!function(e){var n={};function t(o){if(n[o])return n[o].exports;var l=n[o]={i:o,l:!1,exports:{}};return e[o].call(l.exports,l,l.exports,t),l.l=!0,l.exports}t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:o})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var l in e)t.d(o,l,function(n){return e[n]}.bind(null,l));return o},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="/js/",t(t.s=0)}([function(e,n,t){"use strict";t.r(n);t(1),t(2),t(3),t(4),t(5),t(6),t(7),t(8),t(9),t(10),t(11);window.OCA.WorkflowEngine=OCA.WorkflowEngine},function(e,n){ /** * @copyright Copyright (c) 2016 Morris Jobke * * @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 . * */ Handlebars.registerHelper("selectItem",function(e,n){return e===n?'selected="selected"':""}),Handlebars.registerHelper("getOperators",function(e){var n=OCA.WorkflowEngine.getCheckByClass(e);return _.isUndefined(n)?[]:n.operators}),OCA.WorkflowEngine=_.extend(OCA.WorkflowEngine||{},{availablePlugins:[],availableChecks:[],getCheckByClass:function(e){for(var n=OCA.WorkflowEngine.availableChecks.length,t=0;t0?(n.ocs.data.groups.forEach(function(n){e.groups.push({id:n.id,displayname:n.displayname})}),e.render()):(OC.Notification.error(t("workflowengine","Group list is empty"),{type:"error"}),console.log(n))}).error(function(e){OC.Notification.error(t("workflowengine","Unable to retrieve the group list"),{type:"error"}),console.log(e)})},delete:function(){OC.PasswordConfirmation.requiresPasswordConfirmation()?OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.delete,this)):(this.model.destroy(),this.remove())},reset:function(){this.hasChanged=!1,this.model.set(this.originalModel,{silent:!0}),this.render()},save:function(){OC.PasswordConfirmation.requiresPasswordConfirmation()?OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.save,this)):(this.hasChanged=!1,this.saving=!0,this.render(),this.model.save(null,{success:function(e,n,o){this.saving=!1,this.originalModel=JSON.parse(JSON.stringify(this.model)),this.message=t("workflowengine","Saved"),this.errorMessage="",this.render()},error:function(e,n,o){this.saving=!1,this.hasChanged=!0,this.message=t("workflowengine","Saving failed:"),this.errorMessage=n.responseText,this.render()},context:this}))},add:function(){var e=_.clone(this.model.get("checks")),n=OCA.WorkflowEngine.availableChecks[0].class,t=OCA.WorkflowEngine.availableChecks[0].operators;e.push({class:n,operator:t[0].operator,value:""}),this.model.set({checks:e})},checkChanged:function(e){for(var n=e.target.value,t=$(e.target.parentElement).data("id"),o=JSON.parse(JSON.stringify(this.model.get("checks"))),l=null,a=0;a\n'},5:function(e,n,o,l,a,i,r){var s,c,u=null!=n?n:e.nullContext||{},g=o.helperMissing,f=e.escapeExpression;return'\t\t\t
\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t
\n'},6:function(e,n,o,l,a,i,r){var s,c,u=null!=n?n:e.nullContext||{},g=o.helperMissing,f=e.escapeExpression;return'\t\t\t\t\t\t\n"},8:function(e,n,o,l,a,i,r){var s,c,u=null!=n?n:e.nullContext||{},g=o.helperMissing,f=e.escapeExpression;return'\t\t\t\t\t\t\n"},10:function(e,n,t,o,l){var a,i,r=null!=n?n:e.nullContext||{};return(null!=(a=t.if.call(r,null!=(a=null!=n?n.operation:n)?a.id:a,{name:"if",hash:{},fn:e.program(11,l,0),inverse:e.noop,data:l}))?a:"")+'\t\t\n"},11:function(e,n,t,o,l){var a;return'\t\t\t\n"},13:function(e,n,t,o,l){var a;return'\t\t\n\t\t'+e.escapeExpression("function"==typeof(a=null!=(a=t.savingTXT||(null!=n?n.savingTXT:n))?a:t.helperMissing)?a.call(null!=n?n:e.nullContext||{},{name:"savingTXT",hash:{},data:l}):a)+"\n\t"},15:function(e,n,t,o,l){var a;return null!=(a=t.if.call(null!=n?n:e.nullContext||{},null!=n?n.message:n,{name:"if",hash:{},fn:e.program(16,l,0),inverse:e.noop,data:l}))?a:""},16:function(e,n,t,o,l){var a,i,r=null!=n?n:e.nullContext||{};return'\n\t\t\n\t\t\t\t\t'+e.escapeExpression("function"==typeof(i=null!=(i=t.message||(null!=n?n.message:n))?i:t.helperMissing)?i.call(r,{name:"message",hash:{},data:l}):i)+(null!=(a=t.if.call(r,null!=n?n.errorMessage:n,{name:"if",hash:{},fn:e.program(21,l,0),inverse:e.noop,data:l}))?a:"")+"\n\t\t\t\t\n\t"},17:function(e,n,t,o,l){return"error"},19:function(e,n,t,o,l){return"success"},21:function(e,n,t,o,l){var a;return" "+e.escapeExpression("function"==typeof(a=null!=(a=t.errorMessage||(null!=n?n.errorMessage:n))?a:t.helperMissing)?a.call(null!=n?n:e.nullContext||{},{name:"errorMessage",hash:{},data:l}):a)},compiler:[7,">= 4.0.0"],main:function(e,n,o,l,a,i,r){var s,c,u=null!=n?n:e.nullContext||{},g=o.helperMissing,f=e.escapeExpression,d=e.lambda;return'
\n\t
\n\t\t\n\t\t\n'+(null!=(s=o.if.call(u,null!=(s=null!=n?n.operation:n)?s.id:s,{name:"if",hash:{},fn:e.program(3,a,0,i,r),inverse:e.noop,data:a}))?s:"")+'\t
\n\n\t
\n'+(null!=(s=o.each.call(u,null!=(s=null!=n?n.operation:n)?s.checks:s,{name:"each",hash:{},fn:e.program(5,a,0,i,r),inverse:e.noop,data:a}))?s:"")+'\t
\n\t\n"+(null!=(s=o.if.call(u,null!=n?n.hasChanged:n,{name:"if",hash:{},fn:e.program(10,a,0,i,r),inverse:e.noop,data:a}))?s:"")+(null!=(s=o.if.call(u,null!=n?n.saving:n,{name:"if",hash:{},fn:e.program(13,a,0,i,r),inverse:e.program(15,a,0,i,r),data:a}))?s:"")+"\n
\n"},useData:!0,useDepths:!0}),l.operations=o({compiler:[7,">= 4.0.0"],main:function(e,n,t,o,l){var a;return'
\n\n"},useData:!0})},function(e,n){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"),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(e,n){if("OCA\\WorkflowEngine\\Check\\FileMimeType"===n.class){var o="text/plain";"matches"!==n.operator&&"!matches"!==n.operator||(o="/^text\\/(plain|html)$/i",this._validateRegex(n.value)?$(e).removeClass("invalid-input"):$(e).addClass("invalid-input")),$(e).css("width","250px").attr("placeholder",o).attr("title",t("workflowengine","Example: {placeholder}",{placeholder:o})).addClass("has-tooltip").tooltip({placement:"bottom"})}},_validateRegex:function(e){return null!==/^\/(.*)\/([gui]{0,3})$/.exec(e)}},OC.Plugins.register("OCA.WorkflowEngine.CheckPlugins",OCA.WorkflowEngine.Plugins.FileMimeTypePlugin)},function(e,n){OCA.WorkflowEngine=OCA.WorkflowEngine||{},OCA.WorkflowEngine.Plugins=OCA.WorkflowEngine.Plugins||{},OCA.WorkflowEngine.Plugins.FileNamePlugin={getCheck:function(){return{class:"OCA\\WorkflowEngine\\Check\\FileName",name:t("workflowengine","File name"),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(e,n){if("OCA\\WorkflowEngine\\Check\\FileName"===n.class){var o="dummy.jpg";"matches"!==n.operator&&"!matches"!==n.operator||(o="/^dummy-.+$/i",this._validateRegex(n.value)?$(e).removeClass("invalid-input"):$(e).addClass("invalid-input")),$(e).css("width","250px").attr("placeholder",o).attr("title",t("workflowengine","Example: {placeholder}",{placeholder:o})).addClass("has-tooltip").tooltip({placement:"bottom"})}},_validateRegex:function(e){return null!==/^\/(.*)\/([gui]{0,3})$/.exec(e)}},OC.Plugins.register("OCA.WorkflowEngine.CheckPlugins",OCA.WorkflowEngine.Plugins.FileNamePlugin)},function(e,n){OCA.WorkflowEngine=OCA.WorkflowEngine||{},OCA.WorkflowEngine.Plugins=OCA.WorkflowEngine.Plugins||{},OCA.WorkflowEngine.Plugins.FileSizePlugin={getCheck:function(){return{class:"OCA\\WorkflowEngine\\Check\\FileSize",name:t("workflowengine","File size (upload)"),operators:[{operator:"less",name:t("workflowengine","less")},{operator:"!greater",name:t("workflowengine","less or equals")},{operator:"!less",name:t("workflowengine","greater or equals")},{operator:"greater",name:t("workflowengine","greater")}]}},render:function(e,n){"OCA\\WorkflowEngine\\Check\\FileSize"===n.class&&$(e).css("width","250px").attr("placeholder","12 MB").attr("title",t("workflowengine","Example: {placeholder}",{placeholder:"12 MB"})).addClass("has-tooltip").tooltip({placement:"bottom"})}},OC.Plugins.register("OCA.WorkflowEngine.CheckPlugins",OCA.WorkflowEngine.Plugins.FileSizePlugin)},function(e,n){OCA.WorkflowEngine=OCA.WorkflowEngine||{},OCA.WorkflowEngine.Plugins=OCA.WorkflowEngine.Plugins||{},OCA.WorkflowEngine.Plugins.FileSystemTagsPlugin={getCheck:function(){return this.collection=OC.SystemTags.collection,{class:"OCA\\WorkflowEngine\\Check\\FileSystemTags",name:t("workflowengine","File system tag"),operators:[{operator:"is",name:t("workflowengine","is tagged with")},{operator:"!is",name:t("workflowengine","is not tagged with")}]}},render:function(e,n){"OCA\\WorkflowEngine\\Check\\FileSystemTags"===n.class&&($(e).css("width","400px"),$(e).select2({allowClear:!1,multiple:!1,placeholder:t("workflowengine","Select tag…"),query:_.debounce(function(e){e.callback({results:OC.SystemTags.collection.filterByName(e.term)})},100,!0),id:function(e){return e.get("id")},initSelection:function(e,n){n($(e).val())},formatResult:function(e){return OC.SystemTags.getDescriptiveTag(e)},formatSelection:function(e){var n=OC.SystemTags.collection.get(e);if(!_.isUndefined(n))return OC.SystemTags.getDescriptiveTag(n)},escapeMarkup:function(e){return e}}))}},OC.Plugins.register("OCA.WorkflowEngine.CheckPlugins",OCA.WorkflowEngine.Plugins.FileSystemTagsPlugin)},function(e,n){OCA.WorkflowEngine=OCA.WorkflowEngine||{},OCA.WorkflowEngine.Plugins=OCA.WorkflowEngine.Plugins||{},OCA.WorkflowEngine.Plugins.RequestRemoteAddressPlugin={getCheck:function(){return{class:"OCA\\WorkflowEngine\\Check\\RequestRemoteAddress",name:t("workflowengine","Request remote address"),operators:[{operator:"matchesIPv4",name:t("workflowengine","matches IPv4")},{operator:"!matchesIPv4",name:t("workflowengine","does not match IPv4")},{operator:"matchesIPv6",name:t("workflowengine","matches IPv6")},{operator:"!matchesIPv6",name:t("workflowengine","does not match IPv6")}]}},render:function(e,n){if("OCA\\WorkflowEngine\\Check\\RequestRemoteAddress"===n.class){var o="127.0.0.1/32";"matchesIPv6"===n.operator||"!matchesIPv6"===n.operator?(o="::1/128",this._validateIPv6(n.value)?$(e).removeClass("invalid-input"):$(e).addClass("invalid-input")):this._validateIPv4(n.value)?$(e).removeClass("invalid-input"):$(e).addClass("invalid-input"),$(e).css("width","300px").attr("placeholder",o).attr("title",t("workflowengine","Example: {placeholder}",{placeholder:o})).addClass("has-tooltip").tooltip({placement:"bottom"})}},_validateIPv4:function(e){return null!==/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/(3[0-2]|[1-2][0-9]|[1-9])$/.exec(e)},_validateIPv6:function(e){return null!==/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9])$/.exec(e)}},OC.Plugins.register("OCA.WorkflowEngine.CheckPlugins",OCA.WorkflowEngine.Plugins.RequestRemoteAddressPlugin)},function(e,n){OCA.WorkflowEngine=OCA.WorkflowEngine||{},OCA.WorkflowEngine.Plugins=OCA.WorkflowEngine.Plugins||{},OCA.WorkflowEngine.Plugins.RequestTimePlugin={timezones:["Europe/Berlin","Europe/London"],_$element:null,getCheck:function(){return{class:"OCA\\WorkflowEngine\\Check\\RequestTime",name:t("workflowengine","Request time"),operators:[{operator:"in",name:t("workflowengine","between")},{operator:"!in",name:t("workflowengine","not between")}]}},render:function(e,n){if("OCA\\WorkflowEngine\\Check\\RequestTime"===n.class){var o="09:00",l="18:00",a=jstz.determine().name(),i=$(e);if(_.isString(n.value)&&""!==n.value){var r=JSON.parse(n.value),s=r[0].split(" ",2),c=r[1].split(" ",2);o=s[0],l=c[0],a=s[1]}var u=JSON.stringify([o+" "+a,l+" "+a]);n.value!==u&&(n.value=u,i.val(u)),i.css("display","none"),$("").attr("type","text").attr("placeholder",t("workflowengine","Start")).attr("title",t("workflowengine","Example: {placeholder}",{placeholder:"16:00"})).addClass("has-tooltip").tooltip({placement:"bottom"}).addClass("start").val(o).insertBefore(i),$("").attr("type","text").attr("placeholder",t("workflowengine","End")).attr("title",t("workflowengine","Example: {placeholder}",{placeholder:"16:00"})).addClass("has-tooltip").tooltip({placement:"bottom"}).addClass("end").val(l).insertBefore(i);var g=$("").attr("type","hidden").css("width","250px").insertBefore(i).val(a);g.select2({allowClear:!1,multiple:!1,placeholder:t("workflowengine","Select timezone…"),ajax:{url:OC.generateUrl("apps/workflowengine/timezones"),dataType:"json",quietMillis:100,data:function(e){return""===e&&(e=(e=jstz.determine().name().split("/"))[0]),{search:e}},results:function(e){var n=[];return $.each(e,function(e){n.push({id:e})}),{results:n,more:!1}}},initSelection:function(e,n){n(e.val())},formatResult:function(e){return""+e.id+""},formatSelection:function(e){return _.isUndefined(e.id)||(e=e.id),""+e+""}}),g.addClass("timezone"),i.parent().on("change",".start",_.bind(this.update,this)).on("change",".end",_.bind(this.update,this)).on("change",".timezone",_.bind(this.update,this)),this._$element=i}},update:function(e){for(var n=e.target.value,t=null,o=0;o0?n({id:o,displayname:t.find(function(e){return e.id===o}).displayname}):o?n({id:o,displayname:o}):n()},formatResult:function(e){return""+escapeHTML(e.displayname)+""},formatSelection:function(e){return''+escapeHTML(e.displayname)+""}}))}},OC.Plugins.register("OCA.WorkflowEngine.CheckPlugins",OCA.WorkflowEngine.Plugins.UserGroupMembershipPlugin)}]); //# sourceMappingURL=workflowengine.js.map