gd-sprest-bs 10.6.5 → 10.6.7
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/build/webparts/base/wpSPFx.js +7 -6
- package/build/webparts/list/index.js +1 -0
- package/build/webparts/list/wpSPFx.js +6 -6
- package/build/webparts/list/wpSPFxForm.js +286 -0
- package/dist/gd-sprest-bs-icons.js +1 -1
- package/dist/gd-sprest-bs-icons.js.LICENSE.txt +86 -82
- package/dist/gd-sprest-bs-icons.min.js +1 -1
- package/dist/gd-sprest-bs.d.ts +79 -11
- package/dist/gd-sprest-bs.js +1 -1
- package/dist/gd-sprest-bs.js.LICENSE.txt +5 -1
- package/dist/gd-sprest-bs.min.js +1 -1
- package/package.json +2 -2
- package/pnpm-lock.yaml +4 -4
- package/src/webparts/base/types.d.ts +24 -8
- package/src/webparts/base/wpSPFx.ts +8 -6
- package/src/webparts/list/index.ts +2 -1
- package/src/webparts/list/types.d.ts +55 -3
- package/src/webparts/list/wpSPFx.ts +6 -6
- package/src/webparts/list/wpSPFxForm.ts +302 -0
|
@@ -59,7 +59,7 @@ var _SPFxWebPart = /** @class */ (function () {
|
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
61
|
// Set the flag
|
|
62
|
-
this._isEdit = this._props.spfx.displayMode == gd_sprest_1.SPTypes.
|
|
62
|
+
this._isEdit = this._props.spfx.displayMode == gd_sprest_1.SPTypes.DisplayMode.Edit;
|
|
63
63
|
}
|
|
64
64
|
// Set the flag
|
|
65
65
|
this._isDisplay = !this._isEdit;
|
|
@@ -201,11 +201,11 @@ var _SPFxWebPart = /** @class */ (function () {
|
|
|
201
201
|
// Create the form properties
|
|
202
202
|
var formProps = { el: el, value: _this._cfg };
|
|
203
203
|
// Call the rendering event
|
|
204
|
-
formProps = _this._props.
|
|
204
|
+
formProps = _this._props.onConfigFormRendering ? _this._props.onConfigFormRendering(formProps) : formProps;
|
|
205
205
|
// Render the form
|
|
206
206
|
_this._form = gd_bs_1.Components.Form(formProps);
|
|
207
207
|
// Call the rendered event
|
|
208
|
-
_this._props.
|
|
208
|
+
_this._props.onConfigFormRendered ? _this._props.onConfigFormRendered(_this._form) : null;
|
|
209
209
|
},
|
|
210
210
|
onRenderFooter: function (el) {
|
|
211
211
|
// Render the footer buttons
|
|
@@ -230,7 +230,6 @@ var _SPFxWebPart = /** @class */ (function () {
|
|
|
230
230
|
}
|
|
231
231
|
catch (_a) { }
|
|
232
232
|
// Save the configuration
|
|
233
|
-
_this._props.spfxSaveConfig ? _this._props.spfxSaveConfig(wpCfg) : null;
|
|
234
233
|
_this._props.spfx.properties.configuration = wpCfg;
|
|
235
234
|
// Call the saved event
|
|
236
235
|
_this._props.onConfigSaved ? _this._props.onConfigSaved(cfg) : null;
|
|
@@ -248,7 +247,7 @@ var _SPFxWebPart = /** @class */ (function () {
|
|
|
248
247
|
]
|
|
249
248
|
};
|
|
250
249
|
// Call the event
|
|
251
|
-
footerProps = _this._props.
|
|
250
|
+
footerProps = _this._props.onConfigFormFooterRendering ? _this._props.onConfigFormFooterRendering(footerProps) : footerProps;
|
|
252
251
|
// Render the footer
|
|
253
252
|
gd_bs_1.Components.TooltipGroup(footerProps);
|
|
254
253
|
}
|
|
@@ -263,13 +262,15 @@ var _SPFxWebPart = /** @class */ (function () {
|
|
|
263
262
|
this._modal = gd_bs_1.Components.Modal(__assign(__assign({}, newProps), modalProps));
|
|
264
263
|
// Call the rendered event
|
|
265
264
|
this._props.onModalRendered ? this._props.onModalRendered(this._modal) : null;
|
|
265
|
+
// Call the renderEdit event
|
|
266
|
+
this._props.renderEdit ? this._props.renderEdit(elWPConfig, this.Configuration) : null;
|
|
266
267
|
};
|
|
267
268
|
// Shows the modal
|
|
268
269
|
_SPFxWebPart.prototype.showEditModal = function () {
|
|
269
270
|
// Show the modal
|
|
270
271
|
this._modal ? this._modal.show() : null;
|
|
271
272
|
// Call the event
|
|
272
|
-
this._props.
|
|
273
|
+
this._props.onConfigFormDisplaying ? this._props.onConfigFormDisplaying() : null;
|
|
273
274
|
};
|
|
274
275
|
return _SPFxWebPart;
|
|
275
276
|
}());
|
|
@@ -54,7 +54,7 @@ var SPFxListWebPart = function (wpProps) {
|
|
|
54
54
|
// Define the properties
|
|
55
55
|
var baseProps = {
|
|
56
56
|
// Set the form properties
|
|
57
|
-
|
|
57
|
+
onConfigFormRendering: function (props) {
|
|
58
58
|
// Set the controls
|
|
59
59
|
props.controls = [
|
|
60
60
|
{
|
|
@@ -77,12 +77,12 @@ var SPFxListWebPart = function (wpProps) {
|
|
|
77
77
|
}
|
|
78
78
|
];
|
|
79
79
|
// Call the base event
|
|
80
|
-
props = wpProps.
|
|
80
|
+
props = wpProps.onConfigFormRendering ? wpProps.onConfigFormRendering(props) : props;
|
|
81
81
|
// Return the properties
|
|
82
82
|
return props;
|
|
83
83
|
},
|
|
84
84
|
// Footer rendering event
|
|
85
|
-
|
|
85
|
+
onConfigFormFooterRendering: function (props) {
|
|
86
86
|
// Add a load lists button
|
|
87
87
|
props.tooltips.push({
|
|
88
88
|
content: "Loads the lists.",
|
|
@@ -93,19 +93,19 @@ var SPFxListWebPart = function (wpProps) {
|
|
|
93
93
|
}
|
|
94
94
|
});
|
|
95
95
|
// Call the base event
|
|
96
|
-
props = wpProps.
|
|
96
|
+
props = wpProps.onConfigFormFooterRendering ? wpProps.onConfigFormFooterRendering(props) : props;
|
|
97
97
|
// Return the properties
|
|
98
98
|
return props;
|
|
99
99
|
},
|
|
100
100
|
// Modal displaying event
|
|
101
|
-
|
|
101
|
+
onConfigFormDisplaying: function () {
|
|
102
102
|
// See if the lists haven't been loaded
|
|
103
103
|
if (_loadFl == false) {
|
|
104
104
|
// Load the lists
|
|
105
105
|
loadLists(wp.Configuration ? wp.Configuration.ListId : null);
|
|
106
106
|
}
|
|
107
107
|
// Call the base event
|
|
108
|
-
wpProps.
|
|
108
|
+
wpProps.onConfigFormDisplaying ? wpProps.onConfigFormDisplaying() : null;
|
|
109
109
|
},
|
|
110
110
|
// The configuration saving event
|
|
111
111
|
onConfigSaving: function (cfg) {
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.SPFxListFormWebPart = void 0;
|
|
15
|
+
var gd_bs_1 = require("gd-bs");
|
|
16
|
+
var gd_sprest_1 = require("gd-sprest");
|
|
17
|
+
var listForm_1 = require("../../components/listForm");
|
|
18
|
+
var wpSPFx_1 = require("./wpSPFx");
|
|
19
|
+
/**
|
|
20
|
+
* List Form WebPart
|
|
21
|
+
*/
|
|
22
|
+
var SPFxListFormWebPart = function (wpProps) {
|
|
23
|
+
// Set the base properties
|
|
24
|
+
var baseProps = {
|
|
25
|
+
render: function (el, cfg) {
|
|
26
|
+
// Set the list form properties
|
|
27
|
+
var listProps = {
|
|
28
|
+
itemId: wpProps.spfx.context.itemId,
|
|
29
|
+
listName: wpProps.spfx.context.list.title
|
|
30
|
+
};
|
|
31
|
+
// Call the get list information event
|
|
32
|
+
listProps = wpProps.onGetListInfo ? wpProps.onGetListInfo(listProps) : listProps;
|
|
33
|
+
// Load the list information
|
|
34
|
+
gd_sprest_1.Helper.ListForm.create(listProps).then(function (info) {
|
|
35
|
+
// See if this is the display form
|
|
36
|
+
var isDisplay = wpProps.spfx.displayMode == gd_sprest_1.SPTypes.FormDisplayMode.Display;
|
|
37
|
+
if (isDisplay) {
|
|
38
|
+
// Set the display form properties
|
|
39
|
+
var dispProps = {
|
|
40
|
+
el: wpProps.spfx.domElement,
|
|
41
|
+
info: info,
|
|
42
|
+
rowClassName: "mb-3",
|
|
43
|
+
onFormRendered: function (form) {
|
|
44
|
+
// Remove the last class
|
|
45
|
+
form.el.lastChild.classList.remove("mb-3");
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
// Call the rendering event
|
|
49
|
+
dispProps = wpProps.onDisplayFormRendering ? wpProps.onDisplayFormRendering(dispProps) : dispProps;
|
|
50
|
+
// Render the display form
|
|
51
|
+
wp.DisplayForm = listForm_1.ListForm.renderDisplayForm(dispProps);
|
|
52
|
+
// Call the rendered event
|
|
53
|
+
wpProps.onDisplayFormRendered ? wpProps.onDisplayFormRendered(wp.DisplayForm) : null;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// Render the edit form
|
|
57
|
+
var editProps = {
|
|
58
|
+
el: wpProps.spfx.domElement,
|
|
59
|
+
info: info,
|
|
60
|
+
rowClassName: "mb-3",
|
|
61
|
+
controlMode: info.item ? gd_sprest_1.SPTypes.ControlMode.Edit : gd_sprest_1.SPTypes.ControlMode.New,
|
|
62
|
+
onFormRendered: function (form) {
|
|
63
|
+
// Remove the last class
|
|
64
|
+
form.el.lastChild.classList.remove("mb-3");
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
// Call the rendering event
|
|
68
|
+
editProps = wpProps.onEditFormRendering ? wpProps.onEditFormRendering(editProps) : editProps;
|
|
69
|
+
// Render the edit form
|
|
70
|
+
wp.EditForm = listForm_1.ListForm.renderEditForm(editProps);
|
|
71
|
+
// Call the rendered event
|
|
72
|
+
wpProps.onEditFormRendered ? wpProps.onEditFormRendered(wp.EditForm) : null;
|
|
73
|
+
}
|
|
74
|
+
// Render the footer
|
|
75
|
+
var elFooter = document.createElement("div");
|
|
76
|
+
elFooter.classList.add("footer");
|
|
77
|
+
wpProps.spfx.domElement.appendChild(elFooter);
|
|
78
|
+
// Set the footer properties
|
|
79
|
+
var btnSave = null;
|
|
80
|
+
var footerProps = isDisplay ? {
|
|
81
|
+
el: elFooter,
|
|
82
|
+
tooltips: [
|
|
83
|
+
{
|
|
84
|
+
content: "Closes the form.",
|
|
85
|
+
btnProps: {
|
|
86
|
+
text: "Close",
|
|
87
|
+
type: gd_bs_1.Components.ButtonTypes.OutlineDark,
|
|
88
|
+
onClick: function () {
|
|
89
|
+
// Call the close event
|
|
90
|
+
wpProps.spfx.formClosed();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
} : {
|
|
96
|
+
el: elFooter,
|
|
97
|
+
tooltips: [
|
|
98
|
+
{
|
|
99
|
+
content: "Saves the item.",
|
|
100
|
+
btnProps: {
|
|
101
|
+
text: info.item ? "Update" : "Save",
|
|
102
|
+
type: gd_bs_1.Components.ButtonTypes.OutlinePrimary,
|
|
103
|
+
assignTo: function (btn) { btnSave = btn; },
|
|
104
|
+
onClick: function () {
|
|
105
|
+
// Ensure the form is valid
|
|
106
|
+
if (wp.EditForm.isValid()) {
|
|
107
|
+
var values = wp.EditForm.getValues();
|
|
108
|
+
// Disable the button
|
|
109
|
+
btnSave.disable();
|
|
110
|
+
// Call the saving event
|
|
111
|
+
values = wpProps.onSaving ? wpProps.onSaving(values) : values;
|
|
112
|
+
// Save the item
|
|
113
|
+
wp.EditForm.save(values).then(
|
|
114
|
+
// Success
|
|
115
|
+
function (item) {
|
|
116
|
+
// Call the saved event
|
|
117
|
+
wpProps.onSaved ? wpProps.onSaved(item) : null;
|
|
118
|
+
// Enable the button
|
|
119
|
+
btnSave.enable();
|
|
120
|
+
// Call the save event
|
|
121
|
+
wpProps.spfx.formSaved();
|
|
122
|
+
},
|
|
123
|
+
// Error
|
|
124
|
+
function (err) {
|
|
125
|
+
// TODO
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
content: "Cancels the request.",
|
|
133
|
+
btnProps: {
|
|
134
|
+
text: "Cancel",
|
|
135
|
+
type: gd_bs_1.Components.ButtonTypes.OutlineDanger,
|
|
136
|
+
onClick: function () {
|
|
137
|
+
// Call the close event
|
|
138
|
+
wpProps.spfx.formClosed();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
};
|
|
144
|
+
// Call the rendering method
|
|
145
|
+
footerProps = wpProps.onEditFooterRendering ? wpProps.onEditFooterRendering(footerProps) : footerProps;
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
renderEdit: function (el) {
|
|
149
|
+
var elBody = null;
|
|
150
|
+
var elFooter = null;
|
|
151
|
+
// Render a modal
|
|
152
|
+
var modal = gd_bs_1.Components.Modal({
|
|
153
|
+
el: el,
|
|
154
|
+
title: "List Form Configuration (" + wp.Configuration.ListName + ")",
|
|
155
|
+
onRenderBody: function (el) { elBody = el; },
|
|
156
|
+
onRenderFooter: function (el) { elFooter = el; }
|
|
157
|
+
});
|
|
158
|
+
// Render the configure list button
|
|
159
|
+
gd_bs_1.Components.Button({
|
|
160
|
+
el: el,
|
|
161
|
+
text: "Configure List",
|
|
162
|
+
onClick: function () {
|
|
163
|
+
// Ensure a list has been selected
|
|
164
|
+
if (wp.Configuration.ListId) {
|
|
165
|
+
// Show a loading message
|
|
166
|
+
gd_bs_1.Components.Alert({
|
|
167
|
+
el: elBody,
|
|
168
|
+
type: gd_bs_1.Components.AlertTypes.Primary,
|
|
169
|
+
content: "Loading the list data..."
|
|
170
|
+
});
|
|
171
|
+
// Get the content types
|
|
172
|
+
(0, gd_sprest_1.Web)(wp.Configuration.WebUrl).Lists().getById(wp.Configuration.ListId).ContentTypes().execute(function (cts) {
|
|
173
|
+
var items = [];
|
|
174
|
+
// Clear the body
|
|
175
|
+
while (elBody.firstChild) {
|
|
176
|
+
elBody.removeChild(elBody.firstChild);
|
|
177
|
+
}
|
|
178
|
+
// Parse the content types
|
|
179
|
+
for (var i = 0; i < cts.results.length; i++) {
|
|
180
|
+
var ct = cts.results[i];
|
|
181
|
+
// Add the item
|
|
182
|
+
items.push({
|
|
183
|
+
data: ct,
|
|
184
|
+
text: ct.Name,
|
|
185
|
+
value: ct.Id.StringValue
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
// Render a form
|
|
189
|
+
var form = gd_bs_1.Components.Form({
|
|
190
|
+
el: elBody,
|
|
191
|
+
controls: [
|
|
192
|
+
{
|
|
193
|
+
name: "ContentType",
|
|
194
|
+
label: "Content Type",
|
|
195
|
+
type: gd_bs_1.Components.FormControlTypes.Dropdown,
|
|
196
|
+
items: items,
|
|
197
|
+
required: true
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: "ComponentId",
|
|
201
|
+
label: "Component ID",
|
|
202
|
+
type: gd_bs_1.Components.FormControlTypes.TextField,
|
|
203
|
+
required: true
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
name: "ComponentProps",
|
|
207
|
+
label: "Component Properties",
|
|
208
|
+
type: gd_bs_1.Components.FormControlTypes.TextArea
|
|
209
|
+
}
|
|
210
|
+
]
|
|
211
|
+
});
|
|
212
|
+
// Render the footer
|
|
213
|
+
gd_bs_1.Components.TooltipGroup({
|
|
214
|
+
el: elFooter,
|
|
215
|
+
tooltips: [
|
|
216
|
+
{
|
|
217
|
+
content: "Clears the list forms and reverts back to the default forms.",
|
|
218
|
+
btnProps: {
|
|
219
|
+
text: "Clear Custom Forms",
|
|
220
|
+
type: gd_bs_1.Components.ButtonTypes.OutlineDanger,
|
|
221
|
+
onClick: function () {
|
|
222
|
+
// Ensure an item is selected
|
|
223
|
+
if (form.isValid()) {
|
|
224
|
+
var values = form.getValues();
|
|
225
|
+
var item = values["ContentType"];
|
|
226
|
+
// Clear the form component properties
|
|
227
|
+
(0, gd_sprest_1.Web)(wp.Configuration.WebUrl).Lists().getById(wp.Configuration.ListId).ContentTypes(item.value).update({
|
|
228
|
+
DisplayFormClientSideComponentId: null,
|
|
229
|
+
DisplayFormClientSideComponentProperties: null,
|
|
230
|
+
EditFormClientSideComponentId: null,
|
|
231
|
+
EditFormClientSideComponentProperties: null,
|
|
232
|
+
NewFormClientSideComponentId: null,
|
|
233
|
+
NewFormClientSideComponentProperties: null
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
content: "Applies the custom list forms to the selected list.",
|
|
241
|
+
btnProps: {
|
|
242
|
+
text: "Apply Custom Forms",
|
|
243
|
+
type: gd_bs_1.Components.ButtonTypes.OutlineSuccess,
|
|
244
|
+
onClick: function () {
|
|
245
|
+
// Ensure an item is selected
|
|
246
|
+
if (form.isValid()) {
|
|
247
|
+
var values = form.getValues();
|
|
248
|
+
var item = values["ContentType"];
|
|
249
|
+
// Set the form component properties
|
|
250
|
+
(0, gd_sprest_1.Web)(wp.Configuration.WebUrl).Lists().getById(wp.Configuration.ListId).ContentTypes(item.value).update({
|
|
251
|
+
DisplayFormClientSideComponentId: values["ComponentId"],
|
|
252
|
+
DisplayFormClientSideComponentProperties: values["ComponentProps"],
|
|
253
|
+
EditFormClientSideComponentId: values["ComponentId"],
|
|
254
|
+
EditFormClientSideComponentProperties: values["ComponentProps"],
|
|
255
|
+
NewFormClientSideComponentId: values["ComponentId"],
|
|
256
|
+
NewFormClientSideComponentProperties: values["ComponentProps"]
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
]
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
// Display the modal
|
|
266
|
+
modal.show();
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
// Render an error
|
|
270
|
+
gd_bs_1.Components.Alert({
|
|
271
|
+
el: elBody,
|
|
272
|
+
type: gd_bs_1.Components.AlertTypes.Danger,
|
|
273
|
+
content: "Edit the webpart and select a list to apply the solution to."
|
|
274
|
+
});
|
|
275
|
+
// Display the modal
|
|
276
|
+
modal.show();
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
// Return the webpart
|
|
283
|
+
var wp = (0, wpSPFx_1.SPFxListWebPart)(__assign(__assign({}, wpProps), baseProps));
|
|
284
|
+
return wp;
|
|
285
|
+
};
|
|
286
|
+
exports.SPFxListFormWebPart = SPFxListFormWebPart;
|