-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcustom-item-list.js
More file actions
81 lines (74 loc) · 3.19 KB
/
custom-item-list.js
File metadata and controls
81 lines (74 loc) · 3.19 KB
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
(function(eventNames, convenienceApi) {
const eventHandlers = {};
const COLUMN_1_ID = 1000001;
const COLUMN_2_ID = 1000002;
eventHandlers[eventNames.TRANSFORM_LAYOUT] = function(layoutData) {
layoutData.push({
Elements: [{
"View": {
"Name": "Test",
"ArtifactID": 0, // Artifact ID of the view.
"FieldsIds": [COLUMN_1_ID, COLUMN_2_ID], // Artifact IDs of the fields.
"Sorts": [],
"RenderLinks": true,
"HasConditions": false,
"GroupDefinitionFieldName": "",
"QueryHint": "",
ObjectTypeID: 0
},
"FieldCollection": [{
AvfID: COLUMN_1_ID,
"IsVisible": true,
"ItemListType": "Text",
"IsSortable": true,
HeaderName: "Modified By"
},
{
AvfID: COLUMN_2_ID,
"IsVisible": true,
"ItemListType": "Text",
"IsSortable": true,
HeaderName: "Modified On"
}
]
}]
});
};
eventHandlers[eventNames.ITEM_LIST_MODIFY_ACTIONS] = function(itemListActionsApi, itemListView) {
// Override default item list action bar buttons to show no buttons
itemListActionsApi.initialize();
// Add an item list action bar button to refresh the item list
const customAction = itemListActionsApi.addAction(convenienceApi.constants.ACTION_TYPES.NEW);
customAction.title = "Refresh";
customAction.action = function() {
const historyItemListFieldId = self.fieldNameToFieldIdMap.get(HISTORY_ITEM_LIST_NAME);
convenienceApi.fieldHelper.getHtmlElement(historyItemListFieldId).then(function(itemListElement) {
const refreshEvent = document.createEvent("Event");
refreshEvent.initEvent("reloadItemListData", true, true);
itemListElement.dispatchEvent(refreshEvent);
});
}
// Override item list data source
itemListActionsApi.setCustomGetDataFunction(function(category, request) {
// Create some example data to show in the item list with the current date.
// That way the Modified On time will update to the current time when the item list refreshes.
const currentDate = new Date();
const exampleData = [
{
"ArtifactID": 1000010,
"Modified By": "Test User",
"Modified On": currentDate.toString()
}, {
"ArtifactID": 1000011,
"Modified By": "Test User 2",
"Modified On": currentDate.toString()
}
];
return {
TotalCount: exampleData.length,
Results: exampleData
};
});
};
return eventHandlers;
})(eventNames, convenienceApi);