starter.factory('WorkFlow', function ($ionicPopup, $resource, formatFilter, cfg, Tool, showPopup) { var workflow = {}; workflow.templates = $resource(formatFilter('{0}workflow/template/:id', cfg.api)); workflow.templateitem = $resource(formatFilter('{0}workflow/templateitem/', cfg.api)); workflow.templatecc = $resource(formatFilter('{0}workflow/templatecc/', cfg.api)); workflow.templatestep = $resource(formatFilter('{0}workflow/templatestep/', cfg.api)); workflow.templatepermission = $resource(formatFilter('{0}workflow/templatepermission/', cfg.api)); workflow.templatefield = $resource(formatFilter('{0}daily/templatefield/', cfg.api)); workflow.templatedata = {template_id: -1, items: [], steps: [], cc: [], permission: {'depts': [], 'users': [], 'all': true}}; workflow.create_template = function (templatedata) { var template = _.pick(templatedata, "name", "description"); template.type = templatedata.template_id == -1 ? 1 : 0; workflow.templates.save(template, function (data) { var items = _.map(templatedata.items, function (item) { return _.pick(item, 'name', 'required') }) }) }; workflow.showDialog = function (scope, titlename, placeholder, itemlabel, righttext) { var customTemplate = formatFilter( '
{2}