gd-sprest-bs 10.6.6 → 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.
@@ -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.onEditFormRendering ? _this._props.onEditFormRendering(formProps) : formProps;
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.onEditFormRendered ? _this._props.onEditFormRendered(_this._form) : null;
208
+ _this._props.onConfigFormRendered ? _this._props.onConfigFormRendered(_this._form) : null;
209
209
  },
210
210
  onRenderFooter: function (el) {
211
211
  // Render the footer buttons
@@ -247,7 +247,7 @@ var _SPFxWebPart = /** @class */ (function () {
247
247
  ]
248
248
  };
249
249
  // Call the event
250
- footerProps = _this._props.onEditFormFooterRendering ? _this._props.onEditFormFooterRendering(footerProps) : footerProps;
250
+ footerProps = _this._props.onConfigFormFooterRendering ? _this._props.onConfigFormFooterRendering(footerProps) : footerProps;
251
251
  // Render the footer
252
252
  gd_bs_1.Components.TooltipGroup(footerProps);
253
253
  }
@@ -262,13 +262,15 @@ var _SPFxWebPart = /** @class */ (function () {
262
262
  this._modal = gd_bs_1.Components.Modal(__assign(__assign({}, newProps), modalProps));
263
263
  // Call the rendered event
264
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;
265
267
  };
266
268
  // Shows the modal
267
269
  _SPFxWebPart.prototype.showEditModal = function () {
268
270
  // Show the modal
269
271
  this._modal ? this._modal.show() : null;
270
272
  // Call the event
271
- this._props.onEditFormDisplaying ? this._props.onEditFormDisplaying() : null;
273
+ this._props.onConfigFormDisplaying ? this._props.onConfigFormDisplaying() : null;
272
274
  };
273
275
  return _SPFxWebPart;
274
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
- onEditFormRendering: function (props) {
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.onEditFormRendering ? wpProps.onEditFormRendering(props) : props;
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
- onEditFormFooterRendering: function (props) {
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.onEditFormFooterRendering ? wpProps.onEditFormFooterRendering(props) : props;
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
- onEditFormDisplaying: function () {
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.onEditFormDisplaying ? wpProps.onEditFormDisplaying() : null;
108
+ wpProps.onConfigFormDisplaying ? wpProps.onConfigFormDisplaying() : null;
109
109
  },
110
110
  // The configuration saving event
111
111
  onConfigSaving: function (cfg) {
@@ -15,7 +15,7 @@ exports.SPFxListFormWebPart = void 0;
15
15
  var gd_bs_1 = require("gd-bs");
16
16
  var gd_sprest_1 = require("gd-sprest");
17
17
  var listForm_1 = require("../../components/listForm");
18
- var wpSPFx_1 = require("../base/wpSPFx");
18
+ var wpSPFx_1 = require("./wpSPFx");
19
19
  /**
20
20
  * List Form WebPart
21
21
  */
@@ -86,7 +86,8 @@ var SPFxListFormWebPart = function (wpProps) {
86
86
  text: "Close",
87
87
  type: gd_bs_1.Components.ButtonTypes.OutlineDark,
88
88
  onClick: function () {
89
- // TODO
89
+ // Call the close event
90
+ wpProps.spfx.formClosed();
90
91
  }
91
92
  }
92
93
  }
@@ -116,6 +117,8 @@ var SPFxListFormWebPart = function (wpProps) {
116
117
  wpProps.onSaved ? wpProps.onSaved(item) : null;
117
118
  // Enable the button
118
119
  btnSave.enable();
120
+ // Call the save event
121
+ wpProps.spfx.formSaved();
119
122
  },
120
123
  // Error
121
124
  function (err) {
@@ -131,7 +134,8 @@ var SPFxListFormWebPart = function (wpProps) {
131
134
  text: "Cancel",
132
135
  type: gd_bs_1.Components.ButtonTypes.OutlineDanger,
133
136
  onClick: function () {
134
- // TODO
137
+ // Call the close event
138
+ wpProps.spfx.formClosed();
135
139
  }
136
140
  }
137
141
  }
@@ -140,10 +144,143 @@ var SPFxListFormWebPart = function (wpProps) {
140
144
  // Call the rendering method
141
145
  footerProps = wpProps.onEditFooterRendering ? wpProps.onEditFooterRendering(footerProps) : footerProps;
142
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
+ });
143
280
  }
144
281
  };
145
282
  // Return the webpart
146
- var wp = (0, wpSPFx_1.SPFxWebPart)(__assign(__assign({}, wpProps), baseProps));
283
+ var wp = (0, wpSPFx_1.SPFxListWebPart)(__assign(__assign({}, wpProps), baseProps));
147
284
  return wp;
148
285
  };
149
286
  exports.SPFxListFormWebPart = SPFxListFormWebPart;