-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconsole-openModalButton.js
More file actions
49 lines (46 loc) · 1.51 KB
/
console-openModalButton.js
File metadata and controls
49 lines (46 loc) · 1.51 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
/**
* Name: Add Modal Button Console Event Handler
* Description: This event handler adds a button to the console that opens a picker modal when clicked.
*/
(function (eventNames, convenienceApi) {
var eventHandlers = {};
var selectedValues = [];
var dataProvider = convenienceApi.itemListDataProviderFactory.create(
"object",
{
workspaceId: convenienceApi.getCurrentFormState().workspaceId,
objectTypeId: 10,
textIdentifierColumnName: "Control Number",
viewArtifactId: 0, // Use default view for object
}
);
var openCustomPicker = () =>
convenienceApi.modalService
.openMultiListPickerModal({ // or .openSingleListPickerModal
selectedValues: selectedValues,
persistenceKey: "CustomPickerForDocument",
columnsPersistenceKey: "CustomPickerForDocumentColumns",
itemListDataProvider: dataProvider,
rowKeyName: "ArtifactID",
objectTypeId: 10,
label: "Document",
workspaceId: convenienceApi.getCurrentFormState().workspaceId,
})
.then((result) => {
if (!result.wasCancelled) {
selectedValue = result.output;
}
});
eventHandlers[eventNames.CREATE_CONSOLE] = function () {
var button = document.createElement("button");
button.id = "custompicker";
button.textContent = "Open Custom Picker";
button.addEventListener("click", () => {
openCustomPicker();
});
return convenienceApi.console.containersPromise.then(function (containers) {
containers.rootElement.appendChild(button);
});
};
return eventHandlers;
})(eventNames, convenienceApi);