owl-cli 6.79.0 → 6.80.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,100 @@
8
8
  //#import $owl_dfiles:services/modelService.jsx
9
9
  //#import $owl_task_info:services/modelService.jsx
10
10
  //#import $owl_excel_templates:services/modelService.jsx
11
+ //#import excel.js
12
+
13
+ var formSpecs = @formSpecs;
14
+
15
+ var allChoices = {};
16
+
17
+ function getAllChoices(fieldSpec){
18
+ if(fieldSpec._ft==='subform'){
19
+ var fields = fieldSpec.fields;
20
+ for(var i=0;i<fields.length;i++){
21
+ var f = fields[i];
22
+ if(f._ft==='subform'){
23
+ getAllChoices(f);
24
+ }
25
+ else{
26
+ if(f._ft==='field' && f.fieldType==='choice'){
27
+ var optiosMap = {};
28
+ var options = f.options;
29
+ if(options){
30
+ for(var j=0;j<options.length;j++){
31
+ var option = options[j];
32
+ optiosMap[option[0]] = option[1];
33
+ }
34
+ allChoices[f.key] = optiosMap;
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+
42
+
43
+
44
+ function tranverseFields(formSpec, callback, ctx){
45
+ formSpec.fields.forEach( function(field){
46
+ if (field[ '_ft' ] == 'field') {
47
+ callback( field, ctx );
48
+ }
49
+ else if (field[ '_ft' ] == 'subform') {
50
+ var context = { parentField: field }
51
+ tranverseFields( field, callback, context );
52
+ }
53
+ else if (field[ '_ft' ] == 'array') {
54
+ var context = { parentField: field }
55
+ tranverseFields( field, callback, context )
56
+ }
57
+ } );
58
+ }
59
+
60
+ function normalizeValue(value,spec){
61
+ if(value == null){
62
+ return null;
63
+ }
64
+ switch (spec.fieldType){
65
+ case 'string':
66
+ return 's'+value;
67
+ case 'number':
68
+ return 'n' + value;
69
+ case 'date':
70
+ return 'd'+ moment(value).toDate().getTime();
71
+ case 'choice':
72
+ for(var i=0; i<spec.options.length; i++){
73
+ var option = spec.options[i];
74
+ if(option[0]==value){
75
+ return 's'+option[1];
76
+ }
77
+ }
78
+ return 's'+value;
79
+ default:
80
+ return "s"+value;
81
+ }
82
+ }
83
+
84
+ function getExportDoc(obj){
85
+ tranverseFields(formSpecs,function(f,ctx){
86
+ if (ctx.parentField && ctx.parentField._ft == 'array') {
87
+ var items = @projectCodeService.getValue( ctx.parentField.key, obj )
88
+ if(items){
89
+ for(var i=0; i<items.length; i++){
90
+ var item = items[i];
91
+ var value = item[f.origKey];
92
+ value = normalizeValue(value,f);
93
+ item[f.origKey] = value;
94
+ }
95
+ }
96
+ }
97
+ else{
98
+ var value = @projectCodeService.getValue( f.key, obj );
99
+ value = normalizeValue(value,f);
100
+ @projectCodeService.setValue(f.key,value,obj);
101
+ }
102
+ },{});
103
+ return obj;
104
+ }
11
105
 
12
106
  function getAllDocs(searchArgs,sort,tableId,roleId,orgId,loginId,permissions){
13
107
  var keyword = searchArgs.keyword;
@@ -74,6 +168,7 @@ function getDocsByIds(ids){
74
168
  }
75
169
 
76
170
  function main(){
171
+ taskParams = JSON.parse(taskParams);
77
172
  var templateId = taskParams.templateId;
78
173
 
79
174
  var template = owl_excel_templatesService.get(templateId);
@@ -108,13 +203,21 @@ function main(){
108
203
  docs = getAllDocs(searchArgs,sort,tableId,roleId,orgId,loginId,permissions);
109
204
  }
110
205
  else{
111
- var ids = params.ids;
206
+ var ids = taskParams.ids;
112
207
  docs = getDocsByIds(ids);
113
208
  }
209
+
210
+ for(var i=0; i<docs.length; i++){
211
+ var doc = docs[i];
212
+ doc = getExportDoc(doc);
213
+ docs[i] = doc;
214
+ }
215
+
114
216
  if(template.exportType==='doc'){
115
217
  if(outputTarget==='multifile'){
116
218
  for(var i=0; i<docs.length; i++){
117
219
  var exportDoc = docs[i];
220
+
118
221
  var fileId = Excel.generateExcelFromTemplate( templateUrl, exportDoc );
119
222
  if(template.toField){
120
223
  var id=exportDoc.id;
@@ -183,7 +286,6 @@ function main(){
183
286
  name:"" + docName
184
287
  }
185
288
  }
186
-
187
289
  owl_dfilesService.add(download);
188
290
  }
189
291
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owl-cli",
3
- "version": "6.79.0",
3
+ "version": "6.80.0",
4
4
  "main": "index.js",
5
5
  "preferGlobal": true,
6
6
  "bin": {