cityworks 0.0.32 → 0.0.36
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.
- package/README.md +7 -7
- package/dist/case.d.ts +4 -0
- package/dist/case_assets.d.ts +88 -0
- package/dist/case_data.d.ts +1 -1
- package/dist/case_workflow.d.ts +28 -0
- package/dist/cityworks.d.ts +238 -0
- package/dist/comments.d.ts +2 -2
- package/dist/general.d.ts +2 -2
- package/dist/gis.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.m.js +1 -1
- package/dist/index.m.js.map +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.modern.mjs +2 -0
- package/dist/index.modern.mjs.map +1 -0
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/inspection.d.ts +1 -1
- package/dist/request.d.ts +10 -2
- package/dist/workorder.d.ts +7 -7
- package/dist/workorder_admin.d.ts +10 -10
- package/package.json +11 -11
- package/src/case.ts +44 -0
- package/src/case_assets.ts +129 -0
- package/src/case_data.ts +54 -3
- package/src/case_workflow.ts +72 -0
- package/src/cityworks.ts +14 -3
- package/src/comments.ts +4 -4
- package/src/costs.ts +289 -0
- package/src/general.ts +2 -2
- package/src/gis.ts +4 -4
- package/src/inspection.ts +1 -1
- package/src/request.ts +22 -2
- package/src/workorder.ts +7 -7
- package/src/workorder_admin.ts +10 -10
- package/test/08.workOrderTest.js +1 -1
- package/test/09.caseAssetsTest.js +72 -0
package/src/costs.ts
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { CWError } from './error'
|
|
2
|
+
import ReversibleMap from 'reversible-map'
|
|
3
|
+
const _ = require('lodash')
|
|
4
|
+
|
|
5
|
+
export class Costs {
|
|
6
|
+
/**
|
|
7
|
+
* @hidden
|
|
8
|
+
*/
|
|
9
|
+
cw: any
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Storage of all potential activity types which comments can be attached to: Unknown, Request, WorkOrder, CaTask, CaObject, CaCorrection, Project, Contract
|
|
13
|
+
*/
|
|
14
|
+
activityTypes: ReversibleMap<string, number>
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Storage of object's active activityType
|
|
18
|
+
*/
|
|
19
|
+
currentActivityType: string
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @hidden
|
|
23
|
+
*/
|
|
24
|
+
constructor(cw:any, activityType:string) {
|
|
25
|
+
this.cw = cw
|
|
26
|
+
this.activityTypes = new ReversibleMap<string, number>()
|
|
27
|
+
this.activityTypes.set("Request", 1)
|
|
28
|
+
this.activityTypes.set("WorkOrder", 2)
|
|
29
|
+
this.activityTypes.set("Inspection", 3)
|
|
30
|
+
|
|
31
|
+
if(!this.activityTypes.has(activityType)) {
|
|
32
|
+
throw new CWError(1, 'Cost activity type not found.', {'provided': activityType, 'options':this.activityTypes})
|
|
33
|
+
}
|
|
34
|
+
this.currentActivityType = activityType
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Get Cost Codes
|
|
39
|
+
*
|
|
40
|
+
* @category Labor Costs
|
|
41
|
+
* @param {Array<number>} employeeSids - A list of Employee IDs for which to get the job codes.
|
|
42
|
+
* @param {boolean} commonOnly - Set to true to get the Cost Codes that are common to ALL employees in the list, otherwise get all job codes that apply to at least one employee in the list.
|
|
43
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
44
|
+
*/
|
|
45
|
+
getCodes(employeeSids: Object, commonOnly: boolean = false) {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
var data = {
|
|
48
|
+
EmployeeSids: employeeSids,
|
|
49
|
+
CommonCodesOnly: commonOnly
|
|
50
|
+
}
|
|
51
|
+
this.cw.runRequest('Ams/LaborCost/CostCodes', data).then(r => {
|
|
52
|
+
resolve(r.Value)
|
|
53
|
+
}).catch(e => {
|
|
54
|
+
reject(e)
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get Job Codes
|
|
61
|
+
*
|
|
62
|
+
* @category Labor Costs
|
|
63
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
64
|
+
*/
|
|
65
|
+
getJobCodes() {
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
this.cw.runRequest('Ams/LaborCost/JobCodes').then(r => {
|
|
68
|
+
resolve(r.Value)
|
|
69
|
+
}).catch(e => {
|
|
70
|
+
reject(e)
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Add Inspection Labor Costs
|
|
77
|
+
*
|
|
78
|
+
* @category Inspection Costs
|
|
79
|
+
* @param {number} inspectionId - Inspection ID to add labor costs to
|
|
80
|
+
* @param {number} hours - The hours to add to the inspection
|
|
81
|
+
* @param {Object} options - Additional settings for hours setting
|
|
82
|
+
* @param {boolean} estimated - Boolean, get estimated or real costs, defaults to false (get real by default)
|
|
83
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
84
|
+
*/
|
|
85
|
+
addInspectionLabor(inspectionId: number, hours: number, options: object, estimated: boolean = false) {
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
var data = {
|
|
88
|
+
Estimated: estimated,
|
|
89
|
+
InspectionIds: inspectionId,
|
|
90
|
+
Hours: hours
|
|
91
|
+
}
|
|
92
|
+
this.cw.runRequest('Ams/LaborCost/AddInspectionCosts', data).then((response: any) => {
|
|
93
|
+
resolve(response.Value)
|
|
94
|
+
}).catch(e => {
|
|
95
|
+
reject(e)
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get Labor Costs for a specific list of Inspections
|
|
102
|
+
*
|
|
103
|
+
* @category Inspection Costs
|
|
104
|
+
* @param {Array<int>} inspectionIds - An array of inspection IDs to get associated costs for.
|
|
105
|
+
* @param {boolean} estimated - Boolean, get estimated or real costs, defaults to false (get real by default)
|
|
106
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
107
|
+
*/
|
|
108
|
+
getInspectionLabor(inspectionIds: Array<number>, estimated: boolean = false) {
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
var data = {
|
|
111
|
+
Estimated: estimated,
|
|
112
|
+
InspectionIds: inspectionIds
|
|
113
|
+
}
|
|
114
|
+
this.cw.runRequest('Ams/LaborCost/InspectionCostsByInspection', data).then((response: any) => {
|
|
115
|
+
resolve(response.Value)
|
|
116
|
+
}).catch(e => {
|
|
117
|
+
reject(e)
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Delete Inspection Labor Costs
|
|
124
|
+
*
|
|
125
|
+
* @category Inspection Costs
|
|
126
|
+
* @param {Array<int>} laborCostIds - An array of inspection labor cost IDs to delete
|
|
127
|
+
* @param {boolean} estimated - Boolean, delete estimated or real costs, defaults to false (delete real by default)
|
|
128
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
129
|
+
*/
|
|
130
|
+
deleteInspectionLabor(laborCostIds: Array<number>, estimated: boolean = false) {
|
|
131
|
+
return new Promise((resolve, reject) => {
|
|
132
|
+
var data = {
|
|
133
|
+
Estimated: estimated,
|
|
134
|
+
reqLaborCostIds: laborCostIds
|
|
135
|
+
}
|
|
136
|
+
this.cw.runRequest('Ams/LaborCost/DeleteInspectionCosts', data).then((response: any) => {
|
|
137
|
+
resolve(response.Value)
|
|
138
|
+
}).catch(e => {
|
|
139
|
+
reject(e)
|
|
140
|
+
})
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Add Request Labor Costs
|
|
146
|
+
*
|
|
147
|
+
* @category Request Costs
|
|
148
|
+
* @param {Object} requestCosts - Array of inspection labor costings
|
|
149
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
150
|
+
*/
|
|
151
|
+
addRequestLabor(requestCosts: Array<Object>) {
|
|
152
|
+
return new Promise((resolve, reject) => {
|
|
153
|
+
var data = requestCosts
|
|
154
|
+
// ensure each object has Hours & InspectionId
|
|
155
|
+
this.cw.runRequest('Ams/LaborCost/AddRequestCosts', data).then((response: any) => {
|
|
156
|
+
resolve(response.Value)
|
|
157
|
+
}).catch(e => {
|
|
158
|
+
reject(e)
|
|
159
|
+
})
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Get Labor Costs for Request(s)
|
|
165
|
+
*
|
|
166
|
+
* @category Request Costs
|
|
167
|
+
* @param {Object}
|
|
168
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
169
|
+
*/
|
|
170
|
+
// RequestCostsByRequestList<RequestLaborCost>
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Delete Request Labor Costs
|
|
174
|
+
*
|
|
175
|
+
* @category InspeRequestction Costs
|
|
176
|
+
* @param {Object}
|
|
177
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
178
|
+
*/
|
|
179
|
+
// DeleteRequestCostsDictionary<Int32, Boolean>
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Add WorkOrder Labor Costs
|
|
183
|
+
*
|
|
184
|
+
* @category WorkOrder Costs
|
|
185
|
+
* @param {Object}
|
|
186
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
187
|
+
*/
|
|
188
|
+
// AddWorkOrderCostsList<WorkOrderLaborCost>
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Get Labor Costs for WorkOrder(s)
|
|
192
|
+
*
|
|
193
|
+
* @category WorkOrder Costs
|
|
194
|
+
* @param {Object}
|
|
195
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
196
|
+
*/
|
|
197
|
+
// WorkOrderCostsByWorkOrderList<WorkOrderLaborCost>
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Delete WorkOrder Labor Costs
|
|
201
|
+
*
|
|
202
|
+
* @category WorkOrder Costs
|
|
203
|
+
* @param {Object}
|
|
204
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
205
|
+
*/
|
|
206
|
+
// DeleteWorkOrderCostsDictionary<Int32, Boolean>
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Add Inspection Equipment Costs
|
|
210
|
+
*
|
|
211
|
+
* @category Inspection Costs
|
|
212
|
+
* @param {Object}
|
|
213
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
214
|
+
*/
|
|
215
|
+
// AddInspectionCostsList<InspectionEquipmentCost>
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Get Equipment Costs for Inspection(s)
|
|
219
|
+
*
|
|
220
|
+
* @category Inspection Costs
|
|
221
|
+
* @param {Object}
|
|
222
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
223
|
+
*/
|
|
224
|
+
// InspectionCostsByInspectionList<InspectionEquipmentCost>
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Delete Inspection Equipment Costs
|
|
228
|
+
*
|
|
229
|
+
* @category Inspection Costs
|
|
230
|
+
* @param {Object}
|
|
231
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
232
|
+
*/
|
|
233
|
+
// DeleteInspectionCostsDictionary<Int32, Boolean>
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Add WorkOrder Equipment Costs
|
|
237
|
+
*
|
|
238
|
+
* @category WorkOrder Costs
|
|
239
|
+
* @param {Object}
|
|
240
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
241
|
+
*/
|
|
242
|
+
// AddWorkOrderCostsList<EquipmentCost>
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Get Equipment Costs for WorkOrder(s)
|
|
246
|
+
*
|
|
247
|
+
* @category WorkOrder Costs
|
|
248
|
+
* @param {Object}
|
|
249
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
250
|
+
*/
|
|
251
|
+
// WorkOrderCostsByWorkOrderList<EquipmentCost>
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Delete WorkOrder Equipment Costs
|
|
255
|
+
*
|
|
256
|
+
* @category WorkOrder Costs
|
|
257
|
+
* @param {Object}
|
|
258
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
259
|
+
*/
|
|
260
|
+
// DeleteWorkOrderCostsDictionary<Int32, Boolean>
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Add WorkOrder Material Costs
|
|
264
|
+
*
|
|
265
|
+
* @category WorkOrder Costs
|
|
266
|
+
* @param {Object}
|
|
267
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
268
|
+
*/
|
|
269
|
+
// AddWorkOrderCostsList<MaterialCost>
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Get Material Costs for WorkOrder(s)
|
|
273
|
+
*
|
|
274
|
+
* @category WorkOrder Costs
|
|
275
|
+
* @param {Object}
|
|
276
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
277
|
+
*/
|
|
278
|
+
// WorkOrderCostsByWorkOrderList<MaterialCost>
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Delete WorkOrder Material Costs
|
|
282
|
+
*
|
|
283
|
+
* @category WorkOrder Costs
|
|
284
|
+
* @param {Object}
|
|
285
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
286
|
+
*/
|
|
287
|
+
// DeleteWorkOrderCostsDictionary<Int32, Boolean>
|
|
288
|
+
|
|
289
|
+
}
|
package/src/general.ts
CHANGED
|
@@ -102,7 +102,7 @@ export class General {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
|
-
* Get cost summary for
|
|
105
|
+
* Get cost summary for WorkOrder entities
|
|
106
106
|
*
|
|
107
107
|
* @param {Array<number>} ObjectIds
|
|
108
108
|
* @return {Object} Returns Promise object that represents a
|
|
@@ -122,7 +122,7 @@ export class General {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
|
-
* Get cost summary for
|
|
125
|
+
* Get cost summary for WorkOrder entities selected through a search definition
|
|
126
126
|
*
|
|
127
127
|
* @param {number} SearchId - Search Definition Id
|
|
128
128
|
* @return {Object} Returns Promise object that represents a
|
package/src/gis.ts
CHANGED
|
@@ -110,7 +110,7 @@ export class Gis {
|
|
|
110
110
|
/**
|
|
111
111
|
* Get service request gis services
|
|
112
112
|
*
|
|
113
|
-
* @param {number} requestId - The
|
|
113
|
+
* @param {number} requestId - The WorkOrder to check against.
|
|
114
114
|
* @param {boolean} getGisData - If true, check for feature server JSON data, default is true.
|
|
115
115
|
* @return {Object} Returns Promise object that represents an Object with the specified request's entit(y|ies)
|
|
116
116
|
*/
|
|
@@ -132,7 +132,7 @@ export class Gis {
|
|
|
132
132
|
/**
|
|
133
133
|
* Get inspection gis services
|
|
134
134
|
*
|
|
135
|
-
* @param {number} inspectionId - The
|
|
135
|
+
* @param {number} inspectionId - The WorkOrder to check against.
|
|
136
136
|
* @param {boolean} getGisData - If true, check for feature server JSON data, default is true.
|
|
137
137
|
* @return {Object} Returns Promise object that represents an Object with the specified inspection's entity
|
|
138
138
|
*/
|
|
@@ -154,9 +154,9 @@ export class Gis {
|
|
|
154
154
|
/**
|
|
155
155
|
* Get workorder gis services
|
|
156
156
|
*
|
|
157
|
-
* @param {number} workOrderSid - The
|
|
157
|
+
* @param {number} workOrderSid - The WorkOrder to check against.
|
|
158
158
|
* @param {boolean} getGisData - If true, check for feature server JSON data, default is true.
|
|
159
|
-
* @return {Object} Returns Promise object that represents an Object with the specified
|
|
159
|
+
* @return {Object} Returns Promise object that represents an Object with the specified WorkOrder's entit(y|ies)
|
|
160
160
|
*/
|
|
161
161
|
workOrder(workOrderSid, getGisData: boolean = true) {
|
|
162
162
|
return new Promise((resolve, reject) => {
|
package/src/inspection.ts
CHANGED
|
@@ -107,7 +107,7 @@ export class Inspection {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
|
-
* Create an inspection from a
|
|
110
|
+
* Create an inspection from a WorkOrder
|
|
111
111
|
*
|
|
112
112
|
* @category Inspections
|
|
113
113
|
* @param {object} insp_data - See /{subdirectory}/apidocs/#/data-type-infodataType=InspectionBase on your Cityworks instance
|
package/src/request.ts
CHANGED
|
@@ -104,6 +104,26 @@ export class Request {
|
|
|
104
104
|
})
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Update request's map layer fields
|
|
109
|
+
*
|
|
110
|
+
* @category Requests
|
|
111
|
+
* @param {number} requestId
|
|
112
|
+
* @return {Object} Returns Promise that represents an object describing the updated map layer fields
|
|
113
|
+
*/
|
|
114
|
+
updateMLF = (requestId: number) => {
|
|
115
|
+
return new Promise((resolve, reject) => {
|
|
116
|
+
var data = {
|
|
117
|
+
ServiceRequestId: requestId
|
|
118
|
+
}
|
|
119
|
+
this.cw.runRequest('Ams/TemplateMapLayer/ServiceRequestInstanceMapLayersByRequestId', data).then(r => {
|
|
120
|
+
resolve(r.Value)
|
|
121
|
+
}).catch(e => {
|
|
122
|
+
reject(e)
|
|
123
|
+
})
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
107
127
|
/**
|
|
108
128
|
* Change a request's problem code
|
|
109
129
|
*
|
|
@@ -779,11 +799,11 @@ export class Request {
|
|
|
779
799
|
}
|
|
780
800
|
|
|
781
801
|
/**
|
|
782
|
-
* Get
|
|
802
|
+
* Get WorkOrder templates that are associated to this request template type
|
|
783
803
|
*
|
|
784
804
|
* @category Request Templates
|
|
785
805
|
* @param {Array<number>} problemSids - An array list of problemSids to retrieve Problem WO templates for
|
|
786
|
-
* @param {boolean} includeInactiveIf - Include inactive
|
|
806
|
+
* @param {boolean} includeInactiveIf - Include inactive WorkOrder templates, default is false
|
|
787
807
|
* @return {Object} Returns Promise that represents a collection of Problem WO Templates. See /{subdirectory}/apidocs/#/data-type-info;dataType=ProblemWOTemplate
|
|
788
808
|
*/
|
|
789
809
|
getWOTemplates(problemSids: Array<number>, includeInactive: boolean = false) {
|
package/src/workorder.ts
CHANGED
|
@@ -112,8 +112,8 @@ export class WorkOrder {
|
|
|
112
112
|
*
|
|
113
113
|
* @category WorkOrders
|
|
114
114
|
* @param {Array<string>} fromWorkOrderIds - The workorder IDs which should be combined.
|
|
115
|
-
* @param {string} toWorkOrderId - The
|
|
116
|
-
* @param {boolean} cancelCombinedWorkOrders - If the
|
|
115
|
+
* @param {string} toWorkOrderId - The WorkOrder ID for the single WorkOrder that should contain the info/entities from the other WorkOrders
|
|
116
|
+
* @param {boolean} cancelCombinedWorkOrders - If the WorkOrders combined into the single should then be canceled, default is true.
|
|
117
117
|
* @return {Object} Returns object that represents a collection of WorkOrders
|
|
118
118
|
*/
|
|
119
119
|
combine(fromWorkOrderIds: Array<string>, toWorkOrderId: string, cancelCombinedWorkOrders: boolean = true) {
|
|
@@ -362,7 +362,7 @@ export class WorkOrder {
|
|
|
362
362
|
* @category WorkOrders
|
|
363
363
|
* @param {string|number} workOrderSId - The workorder S/ID which the entities should be added to. # for SID, string for ID.
|
|
364
364
|
* @param {Object} entityInfo - Entity info object including: (req) EntityType: {string}, (req) EntityUids: {Array<string>}, Facility_Id: {string}, Level_Id: {string}
|
|
365
|
-
* @param {boolean} updateXY - Update
|
|
365
|
+
* @param {boolean} updateXY - Update WorkOrder xy after adding entit(y|ies), default is true.
|
|
366
366
|
* @return {Object} Returns object that represents a list of entities removed.
|
|
367
367
|
*/
|
|
368
368
|
addEntities(workOrderSId: string|number, entityInfo: Object, updateXY: boolean = true) {
|
|
@@ -441,12 +441,12 @@ export class WorkOrder {
|
|
|
441
441
|
}
|
|
442
442
|
|
|
443
443
|
/**
|
|
444
|
-
* Remove entities from a
|
|
444
|
+
* Remove entities from a WorkOrder. Provide WorkOrderId and either ObjectIds or EntityType and EntityUids
|
|
445
445
|
*
|
|
446
446
|
* @category WorkOrders
|
|
447
447
|
* @param {number} workOrderSId - The workorder S/ID which the entities should be removed from. # for SID, string for ID.
|
|
448
448
|
* @param {Object} entityInfo - Remove entities by WorkOrderEntity.ObjectId (not gis objectId).
|
|
449
|
-
* @param {boolean} updateXY - Update
|
|
449
|
+
* @param {boolean} updateXY - Update WorkOrder xy after removing entities, default is true.
|
|
450
450
|
* @return {Object} Returns object that represents a list of entities removed.
|
|
451
451
|
*/
|
|
452
452
|
removeEntities(workOrderSId: string|number, entityInfo: Object, updateXY: boolean = true) {
|
|
@@ -597,10 +597,10 @@ export class WorkOrder {
|
|
|
597
597
|
* Get WorkOrderS/IDs connected to provided entities
|
|
598
598
|
*
|
|
599
599
|
* @category WorkOrder Search
|
|
600
|
-
* @param {string} entityType - The entity type to find connected
|
|
600
|
+
* @param {string} entityType - The entity type to find connected WorkOrders
|
|
601
601
|
* @param {Array<string>} entityUIDs - The list of entities to search for connected WorkOrders
|
|
602
602
|
* @param {boolean} s - Get WorkOrderSids. Defaults to true. When false, returned list is WorkOrderIds
|
|
603
|
-
* @param {Object} [search] - Any additional search properties of the
|
|
603
|
+
* @param {Object} [search] - Any additional search properties of the WorkOrder (open/closed, etc)
|
|
604
604
|
* @return {Object} Returns Promise that represents an array of WorkOrderS/IDs
|
|
605
605
|
*/
|
|
606
606
|
getWOsByEntities(entityType: string, entityUids: Array<string>, search?: Array<string|number>, s: boolean = true) {
|
package/src/workorder_admin.ts
CHANGED
|
@@ -35,7 +35,7 @@ export class WorkOrderAdmin {
|
|
|
35
35
|
* Get entity types
|
|
36
36
|
*
|
|
37
37
|
* @category WorkOrders Admin
|
|
38
|
-
* @return {Object} Returns Promise that represents a collection of all GIS
|
|
38
|
+
* @return {Object} Returns Promise that represents a collection of all GIS WorkOrder entity types
|
|
39
39
|
*/
|
|
40
40
|
getEntityTypes(entityGroups:Array<string>) {
|
|
41
41
|
return new Promise((resolve, reject) => {
|
|
@@ -49,10 +49,10 @@ export class WorkOrderAdmin {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
* Get
|
|
52
|
+
* Get WorkOrder templates
|
|
53
53
|
*
|
|
54
54
|
* @category WorkOrders Admin
|
|
55
|
-
* @return {Object} Returns Promise that represents a collection of all
|
|
55
|
+
* @return {Object} Returns Promise that represents a collection of all WorkOrder templates
|
|
56
56
|
*/
|
|
57
57
|
getTemplates(entityType:string, includeComments:boolean=true, includeInstructions:boolean=true) {
|
|
58
58
|
return new Promise((resolve, reject) => {
|
|
@@ -66,10 +66,10 @@ export class WorkOrderAdmin {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
|
-
* Update
|
|
69
|
+
* Update WorkOrder template
|
|
70
70
|
*
|
|
71
71
|
* @category WorkOrders Admin
|
|
72
|
-
* @param {Object} wOTemplate - Obect that describes the
|
|
72
|
+
* @param {Object} wOTemplate - Obect that describes the WorkOrder Template
|
|
73
73
|
* @return {Object} Returns Promise that represents a collection of all
|
|
74
74
|
*/
|
|
75
75
|
updateTemplate(wOTemplate:Object) {
|
|
@@ -193,7 +193,7 @@ export class WorkOrderAdmin {
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
/**
|
|
196
|
-
* Get map layer fields configured for provided
|
|
196
|
+
* Get map layer fields configured for provided WorkOrder template
|
|
197
197
|
*
|
|
198
198
|
* @category WorkOrders Admin
|
|
199
199
|
* @param {number} wOTemplateId - WorkOrder Template ID
|
|
@@ -211,11 +211,11 @@ export class WorkOrderAdmin {
|
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
/**
|
|
214
|
-
* Get tasks configured for provided
|
|
214
|
+
* Get tasks configured for provided WorkOrder template
|
|
215
215
|
*
|
|
216
216
|
* @category WorkOrders Admin
|
|
217
217
|
* @param {number} wOTemplateId - WorkOrder Template ID
|
|
218
|
-
* @return {Object} Returns Promise that represents a collection of all tasks on
|
|
218
|
+
* @return {Object} Returns Promise that represents a collection of all tasks on WorkOrder template
|
|
219
219
|
*/
|
|
220
220
|
getTemplateTasks(wOTemplateId:number) {
|
|
221
221
|
return new Promise((resolve, reject) => {
|
|
@@ -229,11 +229,11 @@ export class WorkOrderAdmin {
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
/**
|
|
232
|
-
* Get inspections connected to provided
|
|
232
|
+
* Get inspections connected to provided WorkOrder template
|
|
233
233
|
*
|
|
234
234
|
* @category WorkOrders Admin
|
|
235
235
|
* @param {number} wOTemplateId - WorkOrder Template ID
|
|
236
|
-
* @return {Object} Returns Promise that represents a collection of all tasks on
|
|
236
|
+
* @return {Object} Returns Promise that represents a collection of all tasks on WorkOrder template
|
|
237
237
|
*/
|
|
238
238
|
getRelatedInspectionTemplates(wOTemplateId:number) {
|
|
239
239
|
return new Promise((resolve, reject) => {
|
package/test/08.workOrderTest.js
CHANGED
|
@@ -34,7 +34,7 @@ describe('[WorkOrder (construct)] function test', () => {
|
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
describe('[WorkOrder::create] function test', () => {
|
|
37
|
-
it('should resolve collection of
|
|
37
|
+
it('should resolve collection of WorkOrders', (done) => {
|
|
38
38
|
cw8.workorder.create({WOTemplateId: 209, EntityType: 'MAINTENANCE_CATEGORIZATION'}).then(r => {
|
|
39
39
|
assert.property(r[0], 'WorkOrderSid');
|
|
40
40
|
done();
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
require('dotenv').config();
|
|
3
|
+
var expect = require('chai').expect;
|
|
4
|
+
var assert = require('chai').assert;
|
|
5
|
+
var Cityworks = require('../dist/index.js');
|
|
6
|
+
var cw6 = new Cityworks(process.env.domain, {path: process.env.path});
|
|
7
|
+
const _ = require('lodash')
|
|
8
|
+
|
|
9
|
+
before(function(done) {
|
|
10
|
+
this.timeout(20000000);
|
|
11
|
+
cw6.authenticate(process.env.login, process.env.password).then(resp => {
|
|
12
|
+
done();
|
|
13
|
+
}).catch(e => {
|
|
14
|
+
console.log(e, 'unexpected error')
|
|
15
|
+
done();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe('[CaseAssets (construct)] function test', () => {
|
|
20
|
+
it('should be a defined object', (done) => {
|
|
21
|
+
assert.isObject(cw6.case.financial, 'Request is an object');
|
|
22
|
+
done();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('[CaseAssets::attach] function test', () => {
|
|
27
|
+
it('should resolve a collection of case fees', (done) => {
|
|
28
|
+
cw6.case.financial.getFees(16086).then(r => {
|
|
29
|
+
assert.isArray(r);
|
|
30
|
+
done();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe('[CaseAssets::detach] function test', () => {
|
|
36
|
+
it('should resolve a fee object', (done) => {
|
|
37
|
+
cw6.case.financial.addFee(16085, 183, {}).then(r => {
|
|
38
|
+
assert.isNumber(r.CaFeeId);
|
|
39
|
+
done();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('[CaseAssets::detachAll] function test', () => {
|
|
45
|
+
it('should resolve a fee object', (done) => {
|
|
46
|
+
cw6.case.financial.addFee(16085, 183, {AutoRecalculate: 'Y', Amount: 9}).then(r => {
|
|
47
|
+
assert.isNumber(r.CaFeeId);
|
|
48
|
+
done();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe('[CaseAssets::getForCase] function test', () => {
|
|
54
|
+
it('should resolve a ', (done) => {
|
|
55
|
+
cw6.case.assets.getForCase(42337).then(r => {
|
|
56
|
+
assert.isArray(r);
|
|
57
|
+
done();
|
|
58
|
+
}).catch(e => {
|
|
59
|
+
console.log(e, e)
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe('[CaseAssets::search] function test', () => {
|
|
65
|
+
it('should resolve a fee object with the updated amount', (done) => {
|
|
66
|
+
var newAmount = ((Math.random()*100)*8).toFixed(2);
|
|
67
|
+
cw6.case.assets.search(18480, {}).then(r => { // TODO: ?
|
|
68
|
+
// assert.equal(r.Amount, newAmount);
|
|
69
|
+
done();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|