gd-sprest-bs 10.2.2 → 10.2.5
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/components/listForm/index.js +173 -157
- package/dist/gd-sprest-bs-icons.js +1 -1
- package/dist/gd-sprest-bs-icons.min.js +1 -1
- package/dist/gd-sprest-bs.d.ts +3 -0
- package/dist/gd-sprest-bs.js +1 -1
- package/dist/gd-sprest-bs.min.js +1 -1
- package/package.json +1 -1
- package/src/components/listForm/index.ts +187 -168
- package/src/components/listForm/types.d.ts +3 -0
|
@@ -58,7 +58,7 @@ var getFieldsToRender = function (props) {
|
|
|
58
58
|
var renderDisplay = function (fieldName, props) {
|
|
59
59
|
var control = null;
|
|
60
60
|
var field = props.info.fields[fieldName];
|
|
61
|
-
var isRichText = field.RichText;
|
|
61
|
+
var isRichText = field ? field.RichText : false;
|
|
62
62
|
var value = props.info.fieldValuesAsText[fieldName] || "";
|
|
63
63
|
var html = props.info.fieldValuesAsHtml[fieldName] || props.info.fieldValuesAsHtml[fieldName.replace(/\_/g, "_x005f_")] || "";
|
|
64
64
|
// Ensure the field exists
|
|
@@ -201,44 +201,54 @@ exports.ListForm.renderDisplayForm = function (props) {
|
|
|
201
201
|
});
|
|
202
202
|
var mapper = {};
|
|
203
203
|
var rows = [];
|
|
204
|
-
//
|
|
205
|
-
|
|
206
|
-
//
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
var
|
|
218
|
-
//
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
204
|
+
// Method to generate the attachments row
|
|
205
|
+
var generateAttachmentsRow = function () {
|
|
206
|
+
// See if we are rendering attachments
|
|
207
|
+
var displayAttachments = typeof (props.displayAttachments) === "boolean" ? props.displayAttachments : true;
|
|
208
|
+
if (props.info.attachments && displayAttachments) {
|
|
209
|
+
// Render the attachments
|
|
210
|
+
rows.push({
|
|
211
|
+
columns: [{
|
|
212
|
+
control: {
|
|
213
|
+
id: "ListFormAttachments",
|
|
214
|
+
label: "Attachments",
|
|
215
|
+
name: "Attachments",
|
|
216
|
+
onControlRendered: function (control) {
|
|
217
|
+
var items = [];
|
|
218
|
+
// Parse the attachments
|
|
219
|
+
for (var i = 0; i < props.info.attachments.length; i++) {
|
|
220
|
+
var attachment = props.info.attachments[i];
|
|
221
|
+
// Add the item
|
|
222
|
+
items.push({
|
|
223
|
+
buttons: [{
|
|
224
|
+
className: "me-1",
|
|
225
|
+
href: attachment.ServerRelativeUrl,
|
|
226
|
+
isSmall: true,
|
|
227
|
+
text: attachment.FileName
|
|
228
|
+
}]
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
// Render a toolbar
|
|
232
|
+
core_1.Components.Toolbar({
|
|
233
|
+
el: control.el,
|
|
234
|
+
items: items
|
|
226
235
|
});
|
|
227
236
|
}
|
|
228
|
-
// Render a toolbar
|
|
229
|
-
core_1.Components.Toolbar({
|
|
230
|
-
el: control.el,
|
|
231
|
-
items: items
|
|
232
|
-
});
|
|
233
237
|
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
+
}]
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
};
|
|
238
242
|
// Parse the fields to render
|
|
239
243
|
var fieldNames = getFieldsToRender(props);
|
|
240
244
|
for (var i = 0; i < fieldNames.length; i++) {
|
|
241
245
|
var fieldName = fieldNames[i];
|
|
246
|
+
// See if this is the attachment field
|
|
247
|
+
if (fieldName == "Attachments") {
|
|
248
|
+
// Generate the attachments row
|
|
249
|
+
generateAttachmentsRow();
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
242
252
|
// Generate the control
|
|
243
253
|
var control = renderDisplay(fieldName, props);
|
|
244
254
|
if (control) {
|
|
@@ -431,142 +441,146 @@ exports.ListForm.renderEditForm = function (props) {
|
|
|
431
441
|
label: "Loading the Form",
|
|
432
442
|
size: 100
|
|
433
443
|
});
|
|
434
|
-
//
|
|
435
|
-
|
|
436
|
-
//
|
|
437
|
-
|
|
438
|
-
props.info.
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
if (
|
|
469
|
-
//
|
|
470
|
-
badge.
|
|
444
|
+
// Generates the attachments row
|
|
445
|
+
var generateAttachmentsRow = function () {
|
|
446
|
+
// See if we are rendering attachments
|
|
447
|
+
var displayAttachments = typeof (props.displayAttachments) === "boolean" ? props.displayAttachments : true;
|
|
448
|
+
if (props.info.attachments && displayAttachments) {
|
|
449
|
+
// Set a default field
|
|
450
|
+
// This will help w/ the onControlRendering/ed events to not have a null value for this parameter
|
|
451
|
+
props.info.fields["Attachments"] = {};
|
|
452
|
+
// Render the attachments
|
|
453
|
+
rows.push({
|
|
454
|
+
columns: [{
|
|
455
|
+
control: {
|
|
456
|
+
id: "ListFormAttachments",
|
|
457
|
+
label: "Attachments",
|
|
458
|
+
name: "Attachments",
|
|
459
|
+
onControlRendered: function (control) {
|
|
460
|
+
// Render a toolbar
|
|
461
|
+
var toolbar = core_1.Components.Toolbar({
|
|
462
|
+
el: control.el,
|
|
463
|
+
items: [{
|
|
464
|
+
buttons: [{
|
|
465
|
+
className: "upload-btn me-1",
|
|
466
|
+
isSmall: true,
|
|
467
|
+
text: "Upload",
|
|
468
|
+
type: core_1.Components.ButtonTypes.Secondary,
|
|
469
|
+
onClick: function (btn, ev) {
|
|
470
|
+
var elUpload = ev.currentTarget;
|
|
471
|
+
// Display an upload dialog
|
|
472
|
+
gd_sprest_1.Helper.ListForm.showFileDialog().then(function (fileInfo) {
|
|
473
|
+
// Get the buttons and remove any duplicates
|
|
474
|
+
var buttons = elUpload.parentElement.querySelectorAll(".btn");
|
|
475
|
+
for (var i = 0; i < buttons.length; i++) {
|
|
476
|
+
var button = buttons[i];
|
|
477
|
+
// See if this is the associated button
|
|
478
|
+
if (button.innerText.replace(/X$/, '') == fileInfo.name) {
|
|
479
|
+
// Get the badge
|
|
480
|
+
var badge = button.querySelector(".badge");
|
|
481
|
+
if (badge) {
|
|
482
|
+
// Remove the button
|
|
483
|
+
badge.click();
|
|
484
|
+
}
|
|
485
|
+
break;
|
|
471
486
|
}
|
|
472
|
-
break;
|
|
473
487
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
className: "me-1 file-attachment",
|
|
483
|
-
isSmall: true,
|
|
484
|
-
text: fileInfo.name
|
|
485
|
-
},
|
|
486
|
-
options: {
|
|
487
|
-
content: core_1.Components.Button({
|
|
488
|
-
data: fileInfo,
|
|
488
|
+
// Save the file information
|
|
489
|
+
attachments.new.push(fileInfo);
|
|
490
|
+
// Append the attachment
|
|
491
|
+
elUpload.parentElement.appendChild(core_1.Components.Popover({
|
|
492
|
+
isDismissible: true,
|
|
493
|
+
type: core_1.Components.PopoverPlacements.Bottom,
|
|
494
|
+
btnProps: {
|
|
495
|
+
className: "me-1 file-attachment",
|
|
489
496
|
isSmall: true,
|
|
490
|
-
text:
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
497
|
+
text: fileInfo.name
|
|
498
|
+
},
|
|
499
|
+
options: {
|
|
500
|
+
content: core_1.Components.Button({
|
|
501
|
+
data: fileInfo,
|
|
502
|
+
isSmall: true,
|
|
503
|
+
text: "Remove",
|
|
504
|
+
type: core_1.Components.ButtonTypes.Danger,
|
|
505
|
+
onClick: function (btn, ev) {
|
|
506
|
+
var fileName = btn.data.name;
|
|
507
|
+
// Parse the array
|
|
508
|
+
for (var i = 0; i < attachments.new.length; i++) {
|
|
509
|
+
// See if this is the target attachment
|
|
510
|
+
if (attachments.new[i].name == fileName) {
|
|
511
|
+
// Remove this attachment
|
|
512
|
+
attachments.new.splice(i, 1);
|
|
513
|
+
break;
|
|
514
|
+
}
|
|
501
515
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
516
|
+
// Get the files
|
|
517
|
+
var files = btnGroup.querySelectorAll(".btn.file-attachment");
|
|
518
|
+
for (var i = 0; i < files.length; i++) {
|
|
519
|
+
var file = files[i];
|
|
520
|
+
// See if this is the target button
|
|
521
|
+
if (file.innerText == fileName) {
|
|
522
|
+
// Remove this popover
|
|
523
|
+
file.parentElement.removeChild(file);
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
512
526
|
}
|
|
513
527
|
}
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
})
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
className: "me-1 file-attachment",
|
|
535
|
-
isSmall: true,
|
|
536
|
-
text: attachment.FileName,
|
|
537
|
-
},
|
|
538
|
-
options: {
|
|
539
|
-
content: core_1.Components.Button({
|
|
540
|
-
data: attachment,
|
|
528
|
+
}).el
|
|
529
|
+
}
|
|
530
|
+
}).el);
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
}]
|
|
534
|
+
}]
|
|
535
|
+
});
|
|
536
|
+
// Get the button group
|
|
537
|
+
var btnGroup = toolbar.el.querySelector(".btn-group");
|
|
538
|
+
if (btnGroup) {
|
|
539
|
+
// Parse the attachments
|
|
540
|
+
for (var i = 0; i < props.info.attachments.length; i++) {
|
|
541
|
+
var attachment = props.info.attachments[i];
|
|
542
|
+
// Add the attachment
|
|
543
|
+
btnGroup.appendChild(core_1.Components.Popover({
|
|
544
|
+
isDismissible: true,
|
|
545
|
+
type: core_1.Components.PopoverPlacements.Bottom,
|
|
546
|
+
btnProps: {
|
|
547
|
+
className: "me-1 file-attachment",
|
|
541
548
|
isSmall: true,
|
|
542
|
-
text:
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
var
|
|
552
|
-
//
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
549
|
+
text: attachment.FileName,
|
|
550
|
+
},
|
|
551
|
+
options: {
|
|
552
|
+
content: core_1.Components.Button({
|
|
553
|
+
data: attachment,
|
|
554
|
+
isSmall: true,
|
|
555
|
+
text: "Remove",
|
|
556
|
+
type: core_1.Components.ButtonTypes.Danger,
|
|
557
|
+
onClick: function (btn, ev) {
|
|
558
|
+
var attachment = btn.data;
|
|
559
|
+
// Add this file for deletion
|
|
560
|
+
attachments.delete.push(attachment);
|
|
561
|
+
// Get the files
|
|
562
|
+
var files = btnGroup.querySelectorAll(".btn.file-attachment");
|
|
563
|
+
for (var i_1 = 0; i_1 < files.length; i_1++) {
|
|
564
|
+
var file = files[i_1];
|
|
565
|
+
// See if this is the target button
|
|
566
|
+
if (file.innerText == attachment.FileName) {
|
|
567
|
+
// Remove this popover
|
|
568
|
+
file.parentElement.removeChild(file);
|
|
569
|
+
break;
|
|
570
|
+
}
|
|
557
571
|
}
|
|
558
572
|
}
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
573
|
+
}).el
|
|
574
|
+
}
|
|
575
|
+
}).el);
|
|
576
|
+
}
|
|
563
577
|
}
|
|
564
578
|
}
|
|
565
579
|
}
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
}
|
|
569
|
-
}
|
|
580
|
+
}]
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
};
|
|
570
584
|
// Parse the fields to render
|
|
571
585
|
var fieldNames = getFieldsToRender(props);
|
|
572
586
|
var _loop_1 = function (i) {
|
|
@@ -578,8 +592,10 @@ exports.ListForm.renderEditForm = function (props) {
|
|
|
578
592
|
console.error("[List Form] Field '" + fieldName + "' does not exist. Check the list or query.");
|
|
579
593
|
return "continue";
|
|
580
594
|
}
|
|
581
|
-
//
|
|
595
|
+
// See if this is the attachment field
|
|
582
596
|
if (fieldName == "Attachments") {
|
|
597
|
+
// Generate the attachments row
|
|
598
|
+
generateAttachmentsRow();
|
|
583
599
|
return "continue";
|
|
584
600
|
}
|
|
585
601
|
// See if the item exists
|