vendor/uvdesk/automation-bundle/Resources/views/Workflow/createWorkflow.html.twig line 1

Open in your IDE?
  1. {% extends "@UVDeskCoreFramework/Templates/layout.html.twig" %}
  2. {% block title %}
  3.     {% if app.request.get('id') %}
  4.         {{ 'Edit Workflow' | trans }}
  5.     {% else %}
  6.         {{ 'Add Workflow' | trans }}
  7.     {% endif %}
  8. {% endblock %}
  9. {% block internalcss %}
  10.     @media(max-width: 767px) {
  11.         #company-workflow > .steps {
  12.             display: none;
  13.         }
  14.     }
  15.     @media(max-width: 579px) {
  16.         #company-workflow > h3 {
  17.             margin-right: 80px;
  18.         }
  19.         #company-workflow > h3 > a {
  20.             position: absolute;
  21.             top: 0px;
  22.             right: 10px;
  23.         }
  24.     }
  25.     .has-error button.btn {
  26.         border-color: #cc5965;
  27.     }
  28. {% endblock %}
  29. {% block pageContent %}
  30.     <style>
  31.         .workflow-conditions-body .workflow-condition:first-child .uv-workflow-hr-plank {
  32.             display: none;
  33.         }
  34.         .grammarly-fix-message-container {
  35.             overflow: visible !important;
  36.         }
  37.         .grammarly-fix-message {
  38.             max-width: 120%;
  39.         }
  40.         .textarea-fix-action {
  41.             max-width: 500px !important;
  42.         }
  43.     </style>
  44.     <!-- Inner Section -->
  45.     <div class="uv-inner-section">
  46.         {# Append Panel Aside #}
  47.         {% set asideTemplate = 'Webkul\\UVDesk\\CoreFrameworkBundle\\Dashboard\\AsideTemplate' %}
  48.         {% set asideSidebarReference = 'Webkul\\UVDesk\\CoreFrameworkBundle\\UIComponents\\Dashboard\\Panel\\Sidebars\\Productivity' %}
  49.         {{ uvdesk_extensibles.getRegisteredComponent(asideTemplate).renderSidebar(asideSidebarReference) | raw }}
  50.         
  51.         <!-- View -->
  52.         <div class="uv-view {% if app.request.cookies and app.request.cookies.get('uv-asideView') %}uv-aside-view{% endif %}">
  53.             <!-- Form -->
  54.             {% if app.request.get('id') is not empty %}
  55.                 <h1>{{ 'Edit Workflow'|trans }}</h1>
  56.                 <form class="workflow-form" name="form-workflow" method="POST" action="{{ path('workflows_editaction', {'id': app.request.get('id')}) }}">
  57.             {% else %}
  58.                 <h1>{{ 'New Workflow'|trans }}</h1>
  59.                 <form class="workflow-form" name="form-workflow" method="POST" action="{{ path('workflows_addaction') }}">
  60.             {% endif %}
  61.                 <!-- Workflow Description Section -->
  62.                 <div class="uv-element-block">
  63.                     <label class="uv-field-label">{{ 'Name'|trans }}</label>
  64.                     <div class="uv-field-block">
  65.                         <input name="name" class="uv-field" type="text" value="{{ formData.name is defined ? formData.name : '' }}">
  66.                         <p class="uv-field-message">{% if error.name is defined %}{{ error.name }}{% endif %}</p>
  67.                     </div>
  68.                 </div>
  69.                 <div class="uv-element-block">
  70.                     <label class="uv-field-label">{{ 'Description'|trans }}</label>
  71.                     <div class="uv-field-block grammarly-fix-message-container">
  72.                         <textarea name="description" class="uv-field grammarly-fix-message">{{ formData.description is defined ? formData.description : '' }}</textarea>
  73.                         <p class="uv-field-message">{% if error.description is defined %}{{ error.description }}{% endif %}</p>
  74.                     </div>
  75.                 </div>
  76.                 <div class="uv-element-block">
  77.                     <label class="uv-field-label">{{ 'Workflow Status'|trans }}</label>
  78.                     <div class="uv-element-block">
  79.                         <label>
  80.                             <div class="uv-checkbox">
  81.                                 <input name="status" type="checkbox" {{ formData.status is defined and formData.status == 'on' ? 'checked' : '' }}>
  82.                                 <span class="uv-checkbox-view"></span>
  83.                             </div>
  84.                             <span class="uv-checkbox-label">{{ 'Workflow is Active'|trans }}</span>
  85.                         </label>
  86.                     </div>
  87.                 </div>
  88.                 <div class="uv-hr"></div>
  89.                 <!-- // Workflow Description Section -->
  90.                 <!-- Workflow Events Section -->
  91.                 <div id="events" class="uv-field-workflow">
  92.                     <label class="uv-field-label">{{ 'Events'|trans }}</label>
  93.                     <span class="uv-field-info">{{ "An event automatically triggers to check conditions and perform a respective pre-defined set of actions"|trans }}</span>
  94.                     <div class="workflow-event-body"></div>
  95.                     <div class="uv-workflow-buttons">
  96.                         <a class="uv-btn-tag btn-add" href="#">
  97.                             <span class="uv-icon-add-dark"></span> {{'Add More'|trans}}
  98.                         </a>
  99.                     </div>
  100.                 </div>
  101.                 <div class="uv-hr"></div>
  102.                 <!-- // Workflow Events Section -->
  103.                 <!-- Workflow Conditions Section -->
  104.                 <div id="conditions" class="uv-field-workflow" >
  105.                     <label class="uv-field-label">{{ 'Conditions'|trans }}</label>
  106.                     <span class="uv-field-info">{{ 'Conditions are set of rules which checks for specific scenarios and are triggered on specific occasions'|trans }}</span>
  107.                     <div class="workflow-conditions-body"></div>
  108.                     <div class="uv-workflow-buttons">
  109.                         <a class="uv-btn-tag btn-or" href="#">
  110.                             <span class="uv-icon-add-dark"></span> {{ 'OR'|trans }}
  111.                         </a>
  112.                         <a class="uv-btn-tag btn-and" href="#">
  113.                             <span class="uv-icon-add-dark"></span> {{ 'AND'|trans }}
  114.                         </a>
  115.                     </div>
  116.                 </div>
  117.                 <!-- // Workflow Conditions Section -->
  118.                 <div class="uv-hr"></div>
  119.                 
  120.                 <!-- Workflow Actions Section -->
  121.                 <div id="actions" class="uv-element-block uv-field-workflow">
  122.                     <label class="uv-field-label">{{ 'Actions'|trans }}</label>
  123.                     <span class="uv-field-info">{{ 'An action not only reduces the workload but also makes it quite easier for ticket automation'|trans }}</span>
  124.                     <div class="workflow-action-body"></div>
  125.                     <div class="uv-workflow-buttons">
  126.                         <a class="uv-btn-tag btn-add" href="#">
  127.                             <span class="uv-icon-add-dark"></span> {{ 'Add More'|trans }}
  128.                         </a>
  129.                     </div>
  130.                 </div>
  131.                 <!-- // Workflow Actions Section -->
  132.                 <!-- CTA -->
  133.                 {# <input type="submit" class="uv-btn" href="#" value="Save Workflow"> #}
  134.                 <button type="submit" name="submit" class="uv-btn" href="#">{% if app.request.get('id') is not empty %}{{ 'Save Workflow'|trans }}{% else %}{{ 'Add Workflow'|trans }}{% endif %}</button>
  135.                 <!-- // CTA -->
  136.             </form>
  137.             <!-- Form -->
  138.         </div>
  139.         <!-- // View -->
  140.     </div>
  141.     <!-- // Inner Section -->
  142. {% endblock %}
  143. {% block footer %}
  144.     {{ parent() }}
  145.     <script type="text/javascript">
  146.         _.extend(Backbone.Validation.patterns, {
  147.           stringPattern: /[a-z0-9]/i,
  148.         });
  149.         _.extend(Backbone.Validation.callbacks, {
  150.             valid : function (view, attr, selector) {
  151.                 $('[name="'+attr+'"]').closest('.uv-field-block').find('.uv-field-message').html('').fadeOut(0);
  152.             },
  153.             invalid : function (view, attr, error, selector) {
  154.                 $('[name="'+attr+'"]').closest('.uv-field-block').find('.uv-field-message').html(error).fadeIn(0);
  155.             }
  156.         });
  157.         if(typeof(sB) == 'undefined'){
  158.           var sB = {};
  159.         }
  160.         sB.WorkflowCollection = Backbone.Collection.extend({
  161.             baseUrl: "{{ path('ajax_service_call') }}",
  162.             fetchResult: function(dataMatch) {
  163.             this.url = this.baseUrl;
  164.             return this.fetch({ 'data' : {
  165.                 'service': 'email.service',
  166.                 'call': 'getEmailPlaceHolders',
  167.                 'options': { 'match': dataMatch },
  168.             }});
  169.         }});
  170.         sB.workflowCollection = new sB.WorkflowCollection();
  171.         sB.WorkflowModel = Backbone.Model.extend({
  172.             validation: {
  173.                 name: {
  174.                     required: true,
  175.                     pattern: 'stringPattern',
  176.                     msg: "{{ 'Please enter a valid name.'|trans }}"
  177.                 },
  178.             },
  179.             validateSelect: function(value, attr, computedState) {
  180.                 var currentSelectValue = $('select[name="'+ attr + '"]').find(':selected').length;
  181.                 if (!value) {
  182.                     return "{{ 'Please select a value.'|trans }}";
  183.                 }
  184.             },
  185.             validateSelectMultiple: function(value, attr, computedState) {
  186.                 var currentSelectValue = $('[name="'+ attr + '"]').length;
  187.                 if (!value) {
  188.                     return "{{ 'Please select a value.'|trans }}";
  189.                 }
  190.             },
  191.             validateSelectText: function(value, attr, computedState) {
  192.                 if (!value) {
  193.                     return "{{ 'Please add a value.'|trans }}";
  194.                 }
  195.             }
  196.         });
  197.         sB.WorkflowView = Backbone.View.extend({
  198.             el: '.uv-view',
  199.             initialize: function() {
  200.                 this.model = new sB.WorkflowModel();
  201.                 Backbone.Validation.bind(this);
  202.             },
  203.             events: {
  204.                 'submit form[name="form-workflow"]': 'processWorkflow',
  205.             },
  206.             processWorkflow: function(e) {
  207.                 var disabledCollection = this.$el.find('form').find('[disabled]');
  208.                 if ($(disabledCollection).length > 0) {
  209.                     $.each($(disabledCollection), function(index, nodeElement) {
  210.                         $(nodeElement).removeAttr('disabled');
  211.                     });
  212.                 }
  213.                 this.model.set(this.$el.find('form').serializeObject());
  214.                 var self = this;
  215.                 filterArray = ['name'];
  216.                 // Populate Filter Array - Events and Actions are required fields
  217.                 // Event
  218.                 this.$('.wfEvents').each(function(key, value) {
  219.                     filterArray.push($(value).attr('name'));
  220.                     self.model.validation[$(value).attr('name')] = 'validateSelect';
  221.                 });
  222.                 this.$('.wfEventTriggers').each(function(key, value) {
  223.                     filterArray.push($(value).attr('name'));
  224.                     self.model.validation[$(value).attr('name')] = 'validateSelect';
  225.                 });
  226.                 // Conditions
  227.                 if ($("[name='events[0][event]']").val() == 'ticket' || $("[name='events[0][event]']").val() == 'task') {
  228.                     this.$('.wfCondition').each(function(key, value) {
  229.                         filterArray.push($(value).attr('name'));
  230.                         self.model.validation[$(value).attr('name')] = 'validateSelect';
  231.                     });
  232.                     this.$('.wfConditionMatch').each(function(key, value) {
  233.                         filterArray.push($(value).attr('name'));
  234.                         self.model.validation[$(value).attr('name')] = 'validateSelect';
  235.                     });
  236.                     this.$('.wfConditionValue').each(function(key, value) {
  237.                         if ($(this).attr('name') == undefined) {
  238.                             return;
  239.                         }
  240.                         filterArray.push($(value).attr('name'));
  241.                         self.model.validation[$(value).attr('name')] = 'validateSelectText';
  242.                     });
  243.                 }
  244.                 // Actions
  245.                 this.$('.wfAction').each(function(key, value) {
  246.                     filterArray.push($(value).attr('name'));
  247.                     self.model.validation[$(value).attr('name')] = 'validateSelect';
  248.                 });
  249.                 this.$('.wfActionMultiple').each(function(key, value) {
  250.                     filterArray.push($(value).attr('name'));
  251.                     self.model.validation[$(value).attr('name')] = 'validateSelectMultiple';
  252.                 });
  253.                 this.$('.wfActionValue').each(function(key, value) {
  254.                     if ($(this).attr('name') == undefined) {
  255.                         return;
  256.                     }
  257.                     filterArray.push($(value).attr('name'));
  258.                     self.model.validation[$(value).attr('name')] = 'validateSelectText';
  259.                 });
  260.                 if (this.validateData(filterArray)) {
  261.                     return true;
  262.                 } else {
  263.                     e.preventDefault();
  264.                     if ($(disabledCollection).length > 0) {
  265.                         $.each($(disabledCollection), function(index, nodeElement) {
  266.                             $(nodeElement).attr('disabled', 'disabled');
  267.                         });
  268.                     }
  269.                 }
  270.             },
  271.             validateData: function(filterArray) {
  272.                 return this.model.isValid(filterArray);
  273.             },
  274.             updateActive: function(e){
  275.                 this.$('div.step-info').each(function() {
  276.                     $(this).addClass('active');
  277.                     if ($(this).attr('data-href') == self.$(e.target).attr('href'))
  278.                         return false;
  279.                 });
  280.             }
  281.         });
  282.         sB.workflowView = new sB.WorkflowView();
  283.         $.fn.serializeObject = function () {
  284.             "use strict";
  285.             var a = {}, b = function (b, c) {
  286.                 var d = a[c.name];
  287.                 "undefined" != typeof d && d !== null ? $.isArray(d) ? d.push(c.value) : a[c.name] = [d, c.value] : a[c.name] = c.value
  288.             };
  289.             return $.each(this.serializeArray(), b), a
  290.         };
  291.     </script>
  292.     {{ include('@UVDeskAutomation//Workflow//events.html.twig') }}
  293.     {{ include('@UVDeskAutomation//Workflow//conditions.html.twig') }}
  294.     {{ include('@UVDeskAutomation//Workflow//actions.html.twig') }}
  295. {% endblock %}