File size: 5,310 Bytes
07c3cdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?xml version="1.0" encoding="UTF-8"?>
<dynaForm name="patterns_Select" id="patterns_Select" type="xmlform" width="100%" enableTemplate="1">
  <action type="hidden"/>
  <LANG type="private"/>
  <ROU_UID type="hidden"/>
  <PROCESS type="hidden"/>
  <TASK type="hidden"/>
  <ROU_TYPE_OLD type="hidden"/>
  <TITLE type="title" showInTable="0">
    <en><![CDATA[Selection]]></en>
  </TITLE>
  <ROU_TYPE type="hidden"/>
  <GRID_SELECT_TYPE type="grid" xmlgrid="patterns/patterns_GridSelectType" addRow="1" deleteRow="1" editRow=""/>
  <BTN_CANCEL type="button" onclick="cancel();">
    <en><![CDATA[Cancel]]></en>
  </BTN_CANCEL>
  <SAVE type="button" onclick="savePattern();">
    <en><![CDATA[Save]]></en>
  </SAVE>
  <JS type="javascript"><![CDATA[
var bModified = false;
var modified  = function() {
  bModified   = true;
};
var oGrid          = object_patterns_Select.getElementByName('GRID_SELECT_TYPE');
oGrid.onaddrow     = modified;
oGrid.ondeleterow  = modified;
oGrid.setFunctions([{sFieldName: 'ROU_NEXT_TASK',    sFunction: modified}]);
oGrid.setFunctions([{sFieldName: 'ROU_CONDITION',    sFunction: modified}]);
oGrid.setFunctions([{sFieldName: 'ROU_TO_LAST_USER', sFunction: modified}]);
Pm.tmp.derivationsPanel.events.remove = function() {
  if (bModified) {
    if(confirm(G_STRINGS.ID_SAVE_DERIVATION_RULES_BEFORE_CLOSING)){
	  		savePattern();
	  		return false;
  		}else{
  			return false;
		  }
    
    /*Pm.tmp.derivationsPanel.cancelClose=true;
    new leimnud.module.app.confirm().make({
      label:  G_STRINGS.ID_SAVE_DERIVATION_RULES_BEFORE_CLOSING,
      action: function() {
        Pm.tmp.derivationsPanel.cancelClose=false;
        bModified = false;
        getField('SAVE').onclick();
      }.extend(this),
      cancel: function() {
        bModified = false;
        Pm.tmp.derivationsPanel.cancelClose=false;
        Pm.tmp.derivationsPanel.remove();
      }
    });*/
    return false;
  }
  else {
    return true;
  }
};

var savePattern = function(oForm)
{ oForm=document.getElementById('patterns_Select');
  var oAux;
  var oType     = getField('ROU_TYPE');
  var oOldType  = getField('ROU_TYPE_OLD');
  var i         = 1;
  var aData     = {};
  var bContinue = true;
  if (oType.value != oOldType.value)
  {
    if (!confirm('You are changing the pattern, are you sure?'))
    {
      return false;
    }
  }
  switch (oType.value)
  {
    case 'SELECT':
      var aAux = [];
      while (oAux = document.getElementById('form[GRID_SELECT_TYPE][' + i + '][ROU_NEXT_TASK]'))
      {
        if (!aAux.inArray(oAux.value))
        {
          aAux.push(oAux.value);
        }
        else
        {
          bContinue = false;
        }
        i++;
      }
    break;
    case 'EVALUATE':
      var aAux = [];
      while (oAux = document.getElementById('form[GRID_EVALUATE_TYPE][' + i + '][ROU_NEXT_TASK]'))
      {
        if (!aAux.inArray(oAux.value))
        {
          aAux.push(oAux.value);
        }
        else
        {
          bContinue = false;
        }
        i++;
      }
    break;
    case 'PARALLEL':
      var aAux = [];
      while (oAux = document.getElementById('form[GRID_PARALLEL_TYPE][' + i + '][ROU_NEXT_TASK]'))
      {
        if (!aAux.inArray(oAux.value))
        {
          aAux.push(oAux.value);
        }
        else
        {
          bContinue = false;
        }
        i++;
      }
    break;
    case 'PARALLEL-BY-EVALUATION':
      var aAux = [];
      while (oAux = document.getElementById('form[GRID_PARALLEL_EVALUATION_TYPE][' + i + '][ROU_NEXT_TASK]'))
      {
        if (!aAux.inArray(oAux.value))
        {
          aAux.push(oAux.value);
        }
        else
        {
          bContinue = false;
        }
        i++;
      }
    break;
  }
  if (!bContinue)
  {
    alert('You cannot select to the same task several times!');
    return bContinue;
  }
  i             = 1;
  aData.tas_uid = getField('TASK').value;
  aData.data    = [];
  switch (oType.value)
  {
    case 'SEQUENTIAL':
      aData.type = 0;
      aData.data.push(getField('ROU_NEXT_TASK').value);
    break;
    case 'SELECT':
      aData.type = 1;
      while (oAux = document.getElementById('form[GRID_SELECT_TYPE][' + i + '][ROU_NEXT_TASK]'))
      {
        aData.data.push(oAux.value);
        i++;
      }

    break;
    case 'EVALUATE':
      aData.type = 2;
      while (oAux = document.getElementById('form[GRID_EVALUATE_TYPE][' + i + '][ROU_NEXT_TASK]'))
      {
        aData.data.push(oAux.value);
        i++;
      }
    break;
    case 'PARALLEL':
      aData.type = 3;
      while (oAux = document.getElementById('form[GRID_PARALLEL_TYPE][' + i + '][ROU_NEXT_TASK]'))
      {
        aData.data.push(oAux.value);
        i++;
      }
    break;
    case 'PARALLEL-BY-EVALUATION':
      aData.type = 4;
      while (oAux = document.getElementById('form[GRID_PARALLEL_EVALUATION_TYPE][' + i + '][ROU_NEXT_TASK]'))
      {
        aData.data.push(oAux.value);
        i++;
      }
    break;
    case 'SEC-JOIN':
      aData.type = 5;
      aData.data.push(getField('ROU_NEXT_TASK').value);
    break;
  }
  Pm.data.build.derivation(aData);
  ajax_post(oForm.action, oForm, 'POST');
  bModified = false;
  Pm.tmp.derivationsPanel.remove();
};

function cancel(){
    Pm.tmp.derivationsPanel.remove();
}

]]></JS>
</dynaForm>