gd-sprest-bs 10.2.4 → 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.
|
@@ -201,45 +201,54 @@ exports.ListForm.renderDisplayForm = function (props) {
|
|
|
201
201
|
});
|
|
202
202
|
var mapper = {};
|
|
203
203
|
var rows = [];
|
|
204
|
-
//
|
|
205
|
-
var
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
|
227
235
|
});
|
|
228
236
|
}
|
|
229
|
-
// Render a toolbar
|
|
230
|
-
core_1.Components.Toolbar({
|
|
231
|
-
el: control.el,
|
|
232
|
-
items: items
|
|
233
|
-
});
|
|
234
237
|
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
}
|
|
238
|
+
}]
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
};
|
|
239
242
|
// Parse the fields to render
|
|
240
243
|
var fieldNames = getFieldsToRender(props);
|
|
241
244
|
for (var i = 0; i < fieldNames.length; i++) {
|
|
242
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
|
+
}
|
|
243
252
|
// Generate the control
|
|
244
253
|
var control = renderDisplay(fieldName, props);
|
|
245
254
|
if (control) {
|
|
@@ -432,143 +441,146 @@ exports.ListForm.renderEditForm = function (props) {
|
|
|
432
441
|
label: "Loading the Form",
|
|
433
442
|
size: 100
|
|
434
443
|
});
|
|
435
|
-
//
|
|
436
|
-
var
|
|
437
|
-
|
|
438
|
-
|
|
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
|
-
var
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
//
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
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;
|
|
473
486
|
}
|
|
474
|
-
break;
|
|
475
487
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
className: "me-1 file-attachment",
|
|
485
|
-
isSmall: true,
|
|
486
|
-
text: fileInfo.name
|
|
487
|
-
},
|
|
488
|
-
options: {
|
|
489
|
-
content: core_1.Components.Button({
|
|
490
|
-
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",
|
|
491
496
|
isSmall: true,
|
|
492
|
-
text:
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
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
|
+
}
|
|
503
515
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
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
|
+
}
|
|
514
526
|
}
|
|
515
527
|
}
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
})
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
className: "me-1 file-attachment",
|
|
537
|
-
isSmall: true,
|
|
538
|
-
text: attachment.FileName,
|
|
539
|
-
},
|
|
540
|
-
options: {
|
|
541
|
-
content: core_1.Components.Button({
|
|
542
|
-
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",
|
|
543
548
|
isSmall: true,
|
|
544
|
-
text:
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
var
|
|
554
|
-
//
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
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
|
+
}
|
|
559
571
|
}
|
|
560
572
|
}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
}
|
|
573
|
+
}).el
|
|
574
|
+
}
|
|
575
|
+
}).el);
|
|
576
|
+
}
|
|
565
577
|
}
|
|
566
578
|
}
|
|
567
579
|
}
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
}
|
|
571
|
-
}
|
|
580
|
+
}]
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
};
|
|
572
584
|
// Parse the fields to render
|
|
573
585
|
var fieldNames = getFieldsToRender(props);
|
|
574
586
|
var _loop_1 = function (i) {
|
|
@@ -580,8 +592,10 @@ exports.ListForm.renderEditForm = function (props) {
|
|
|
580
592
|
console.error("[List Form] Field '" + fieldName + "' does not exist. Check the list or query.");
|
|
581
593
|
return "continue";
|
|
582
594
|
}
|
|
583
|
-
//
|
|
595
|
+
// See if this is the attachment field
|
|
584
596
|
if (fieldName == "Attachments") {
|
|
597
|
+
// Generate the attachments row
|
|
598
|
+
generateAttachmentsRow();
|
|
585
599
|
return "continue";
|
|
586
600
|
}
|
|
587
601
|
// See if the item exists
|