-
-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathEditTag.js
95 lines (81 loc) · 2.4 KB
/
EditTag.js
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
let ourDialog;
function showEditTagDialog(tag, cancelFunction, okFunction, removeFunction) {
let title = `Editing tag: '${tag}'`;
let subject = `Provide new name for the tag:`;
if (!ourDialog) {
ourDialog = document.createElement("dialog");
ourDialog.innerHTML = `
<style>
form {
width: 360px;
}
.h1 {
align-items: center;
justify-content: space-between;
display: flex;
flex-direction: row;
}
.icon {
border-radius: 4px;
width: 24px;
height: 24px;
overflow: hidden;
}
.flex-container {
display: flex;
flex-direction: row;
}
.flex-container > .flex-item {
flex: auto;
}
.flex-container > .raw-item {
flex-grow: 1;
}
</style>
<form method="dialog">
<h1 class="h1">
<span>${title}</span>
</h1>
<hr />
<p>${subject}</p>
<label>
<input type="string" uxp-quiet="true" id="newTagName" value="" placeholder="${tag}"/>
</label>
<div class="flex-container">
</div>
<footer>
<button id="editRemove" class="raw-item" uxp-variant="secondary">Remove</button>
<button id="editCancel" class="raw-item" uxp-variant="primary">Cancel</button>
<button id="editOk" class="raw-item" uxp-variant="cta">Ok</button>
</footer>
</form>
`;
document.appendChild(ourDialog);
let editCancel = document.querySelector("#editCancel");
let editOk = document.querySelector("#editOk");
let editRemove = document.querySelector("#editRemove");
let newTagName = document.querySelector("#newTagName");
function removeOurDialog() {
document.removeChild(ourDialog);
ourDialog = null;
}
editCancel.addEventListener("click"
, e => {
ourDialog.close("editCancel");
removeOurDialog();
cancelFunction();
});
editOk.addEventListener("click", e => {
ourDialog.close("editOk");
removeOurDialog();
okFunction(newTagName.value);
});
editRemove.addEventListener("click", e => {
ourDialog.close("editRemove");
removeOurDialog();
removeFunction();
});
}
return ourDialog.showModal();
}
module.exports.showEditTagDialog = showEditTagDialog;