gd-sprest-bs 9.2.8 → 9.3.1
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 +113 -140
- package/dist/gd-sprest-bs-icons.js +246 -246
- package/dist/gd-sprest-bs-icons.min.js +1 -1
- package/dist/gd-sprest-bs.js +5 -5
- package/dist/gd-sprest-bs.min.js +1 -1
- package/package.json +2 -2
- package/pnpm-lock.yaml +4 -4
- package/src/components/listForm/index.ts +122 -153
|
@@ -42,6 +42,102 @@ var getFieldsToRender = function (props) {
|
|
|
42
42
|
// Return the field names
|
|
43
43
|
return fieldNames;
|
|
44
44
|
};
|
|
45
|
+
// Method to render the display control
|
|
46
|
+
var renderDisplay = function (fieldName, props) {
|
|
47
|
+
var control = null;
|
|
48
|
+
var field = props.info.fields[fieldName];
|
|
49
|
+
var value = props.info.fieldValuesAsText[fieldName] || "";
|
|
50
|
+
var html = props.info.fieldValuesAsHtml[fieldName] || props.info.fieldValuesAsHtml[fieldName.replace(/\_/g, "_x005f_")] || "";
|
|
51
|
+
// Ensure the field exists
|
|
52
|
+
if (field == null) {
|
|
53
|
+
// Log
|
|
54
|
+
console.error("[List Form] Field '" + fieldName + "' does not exist. Check the list or query.");
|
|
55
|
+
return control;
|
|
56
|
+
}
|
|
57
|
+
// See if we are hiding the field
|
|
58
|
+
if (field.SchemaXml.indexOf('ShowInDisplayForm="FALSE"') > 0) {
|
|
59
|
+
return control;
|
|
60
|
+
}
|
|
61
|
+
// See if this is a note field
|
|
62
|
+
if (field.FieldTypeKind == gd_sprest_1.SPTypes.FieldType.Note) {
|
|
63
|
+
// Update the html
|
|
64
|
+
html = html.replace(/\r?\n/g, '<br />');
|
|
65
|
+
}
|
|
66
|
+
// Else, see if this is a user field
|
|
67
|
+
else if (field.FieldTypeKind == gd_sprest_1.SPTypes.FieldType.User) {
|
|
68
|
+
// See if this is a multi-user selection
|
|
69
|
+
if (field.AllowMultipleValues) {
|
|
70
|
+
var userNames = [];
|
|
71
|
+
// Parse the users
|
|
72
|
+
var users = (props.info.item[fieldName] ? props.info.item[fieldName].results : null) || [];
|
|
73
|
+
for (var j = 0; j < users.length; j++) {
|
|
74
|
+
// Append the user name
|
|
75
|
+
userNames.push(users[j].Title);
|
|
76
|
+
}
|
|
77
|
+
// Set the html value
|
|
78
|
+
html = userNames.join('<br />\n');
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// Extract the text only for single selections
|
|
82
|
+
var elUser = document.createElement("div");
|
|
83
|
+
elUser.innerHTML = html;
|
|
84
|
+
html = elUser.innerText;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Else, see if this is a choice field
|
|
88
|
+
else if (field.FieldTypeKind == gd_sprest_1.SPTypes.FieldType.Choice || field.FieldTypeKind == gd_sprest_1.SPTypes.FieldType.MultiChoice) {
|
|
89
|
+
// Update the html
|
|
90
|
+
html = value;
|
|
91
|
+
}
|
|
92
|
+
// Set the control
|
|
93
|
+
control = {
|
|
94
|
+
data: html,
|
|
95
|
+
description: field.Description,
|
|
96
|
+
isReadonly: true,
|
|
97
|
+
label: field.Title,
|
|
98
|
+
name: field.InternalName,
|
|
99
|
+
type: core_1.Components.FormControlTypes.TextField,
|
|
100
|
+
value: html
|
|
101
|
+
};
|
|
102
|
+
// Update the type, based on the field
|
|
103
|
+
switch (field.FieldTypeKind) {
|
|
104
|
+
case gd_sprest_1.SPTypes.FieldType.DateTime:
|
|
105
|
+
// Set the time flag
|
|
106
|
+
control.showTime = field.DisplayFormat == gd_sprest_1.SPTypes.DateFormat.DateTime ? true : false;
|
|
107
|
+
// Set the type
|
|
108
|
+
control.type = datetime_1.DateTimeControlType;
|
|
109
|
+
break;
|
|
110
|
+
case gd_sprest_1.SPTypes.FieldType.Note:
|
|
111
|
+
// Set the type
|
|
112
|
+
control.type = core_1.Components.FormControlTypes.TextArea;
|
|
113
|
+
break;
|
|
114
|
+
case gd_sprest_1.SPTypes.FieldType.User:
|
|
115
|
+
// Set the type
|
|
116
|
+
control.type = field.AllowMultipleValues ? core_1.Components.FormControlTypes.TextArea : control.type;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
// Detect html
|
|
120
|
+
if (/<*>/g.test(html)) {
|
|
121
|
+
// Update the control to be read-only
|
|
122
|
+
control.type = core_1.Components.FormControlTypes.Readonly;
|
|
123
|
+
// Set the rendered event
|
|
124
|
+
control.onControlRendered = function (control) {
|
|
125
|
+
// Set the class name
|
|
126
|
+
control.el.classList.add("form-control");
|
|
127
|
+
control.el.style.backgroundColor = "#e9ecef";
|
|
128
|
+
// Override the html rendered
|
|
129
|
+
control.el.innerHTML = control.props.data;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
// Else, detect xml
|
|
133
|
+
else if (/</g.test(html)) {
|
|
134
|
+
// Update the value
|
|
135
|
+
control.value = html.replace(/</g, '<')
|
|
136
|
+
.replace(/>/g, '>')
|
|
137
|
+
.replace(/&/g, '&')
|
|
138
|
+
.replace(/"/g, '"');
|
|
139
|
+
}
|
|
140
|
+
};
|
|
45
141
|
// Method to render a display form for an item
|
|
46
142
|
exports.ListForm.renderDisplayForm = function (props) {
|
|
47
143
|
var form = null;
|
|
@@ -93,104 +189,16 @@ exports.ListForm.renderDisplayForm = function (props) {
|
|
|
93
189
|
var fieldNames = getFieldsToRender(props);
|
|
94
190
|
for (var i = 0; i < fieldNames.length; i++) {
|
|
95
191
|
var fieldName = fieldNames[i];
|
|
96
|
-
|
|
97
|
-
var
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
// See if we are hiding the field
|
|
106
|
-
if (field.SchemaXml.indexOf('ShowInDisplayForm="FALSE"') > 0) {
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
// See if this is a note field
|
|
110
|
-
if (field.FieldTypeKind == gd_sprest_1.SPTypes.FieldType.Note) {
|
|
111
|
-
// Update the html
|
|
112
|
-
html = html.replace(/\r?\n/g, '<br />');
|
|
113
|
-
}
|
|
114
|
-
// Else, see if this is a user field
|
|
115
|
-
else if (field.FieldTypeKind == gd_sprest_1.SPTypes.FieldType.User) {
|
|
116
|
-
// See if this is a multi-user selection
|
|
117
|
-
if (field.AllowMultipleValues) {
|
|
118
|
-
var userNames = [];
|
|
119
|
-
// Parse the users
|
|
120
|
-
var users = (props.info.item[fieldName] ? props.info.item[fieldName].results : null) || [];
|
|
121
|
-
for (var j = 0; j < users.length; j++) {
|
|
122
|
-
// Append the user name
|
|
123
|
-
userNames.push(users[j].Title);
|
|
124
|
-
}
|
|
125
|
-
// Set the html value
|
|
126
|
-
html = userNames.join('<br />\n');
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
// Extract the text only for single selections
|
|
130
|
-
var elUser = document.createElement("div");
|
|
131
|
-
elUser.innerHTML = html;
|
|
132
|
-
html = elUser.innerText;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
// Else, see if this is a choice field
|
|
136
|
-
else if (field.FieldTypeKind == gd_sprest_1.SPTypes.FieldType.Choice || field.FieldTypeKind == gd_sprest_1.SPTypes.FieldType.MultiChoice) {
|
|
137
|
-
// Update the html
|
|
138
|
-
html = value;
|
|
139
|
-
}
|
|
140
|
-
// Set the control
|
|
141
|
-
mapper[fieldName] = {
|
|
142
|
-
data: html,
|
|
143
|
-
description: field.Description,
|
|
144
|
-
isReadonly: true,
|
|
145
|
-
label: field.Title,
|
|
146
|
-
name: field.InternalName,
|
|
147
|
-
type: core_1.Components.FormControlTypes.TextField,
|
|
148
|
-
value: html
|
|
149
|
-
};
|
|
150
|
-
// Update the type, based on the field
|
|
151
|
-
switch (field.FieldTypeKind) {
|
|
152
|
-
case gd_sprest_1.SPTypes.FieldType.DateTime:
|
|
153
|
-
// Set the time flag
|
|
154
|
-
mapper[fieldName].showTime = field.DisplayFormat == gd_sprest_1.SPTypes.DateFormat.DateTime ? true : false;
|
|
155
|
-
// Set the type
|
|
156
|
-
mapper[fieldName].type = datetime_1.DateTimeControlType;
|
|
157
|
-
break;
|
|
158
|
-
case gd_sprest_1.SPTypes.FieldType.Note:
|
|
159
|
-
// Set the type
|
|
160
|
-
mapper[fieldName].type = core_1.Components.FormControlTypes.TextArea;
|
|
161
|
-
break;
|
|
162
|
-
case gd_sprest_1.SPTypes.FieldType.User:
|
|
163
|
-
// Set the type
|
|
164
|
-
mapper[fieldName].type = field.AllowMultipleValues ? core_1.Components.FormControlTypes.TextArea : mapper[fieldName].type;
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
// Detect html
|
|
168
|
-
if (/<*>/g.test(html)) {
|
|
169
|
-
// Update the control to be read-only
|
|
170
|
-
mapper[fieldName].type = core_1.Components.FormControlTypes.Readonly;
|
|
171
|
-
// Set the rendered event
|
|
172
|
-
mapper[fieldName].onControlRendered = function (control) {
|
|
173
|
-
// Set the class name
|
|
174
|
-
control.el.classList.add("form-control");
|
|
175
|
-
control.el.style.backgroundColor = "#e9ecef";
|
|
176
|
-
// Override the html rendered
|
|
177
|
-
control.el.innerHTML = control.props.data;
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
// Else, detect xml
|
|
181
|
-
else if (/</g.test(html)) {
|
|
182
|
-
// Update the value
|
|
183
|
-
mapper[fieldName].value = html.replace(/</g, '<')
|
|
184
|
-
.replace(/>/g, '>')
|
|
185
|
-
.replace(/&/g, '&')
|
|
186
|
-
.replace(/"/g, '"');
|
|
192
|
+
// Generate the control
|
|
193
|
+
var control = renderDisplay(fieldName, props);
|
|
194
|
+
if (control) {
|
|
195
|
+
// Update the mapper
|
|
196
|
+
mapper[fieldName] = control;
|
|
197
|
+
// Add the row
|
|
198
|
+
rows.push({
|
|
199
|
+
columns: [{ control: control }]
|
|
200
|
+
});
|
|
187
201
|
}
|
|
188
|
-
// Add the row
|
|
189
|
-
rows.push({
|
|
190
|
-
columns: [{
|
|
191
|
-
control: mapper[fieldName]
|
|
192
|
-
}]
|
|
193
|
-
});
|
|
194
202
|
}
|
|
195
203
|
// See if there is a template
|
|
196
204
|
if (props.template) {
|
|
@@ -671,49 +679,14 @@ exports.ListForm.renderEditForm = function (props) {
|
|
|
671
679
|
var updateReadOnly = function (control) {
|
|
672
680
|
// See if this control is readonly
|
|
673
681
|
if (control.isReadonly) {
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
control.type = core_1.Components.FormControlTypes.Readonly;
|
|
683
|
-
// Detect html
|
|
684
|
-
if (/<*>/g.test(html_1)) {
|
|
685
|
-
// Update the control properties
|
|
686
|
-
control.data = html_1;
|
|
687
|
-
}
|
|
688
|
-
// Set the rendered event
|
|
689
|
-
control.onControlRendered = function (control) {
|
|
690
|
-
// Set the class name
|
|
691
|
-
control.el.classList.add("form-control");
|
|
692
|
-
control.el.style.backgroundColor = "#e9ecef";
|
|
693
|
-
// Override the html rendered
|
|
694
|
-
control.el.innerHTML = html_1 || control.props.value;
|
|
695
|
-
};
|
|
696
|
-
// See if this is a user field
|
|
697
|
-
if (field.FieldTypeKind == gd_sprest_1.SPTypes.FieldType.User) {
|
|
698
|
-
// See if this is a multi-user selection
|
|
699
|
-
if (field.AllowMultipleValues) {
|
|
700
|
-
var userNames = [];
|
|
701
|
-
// Parse the users
|
|
702
|
-
var users = (props.info.item[field.InternalName] ? props.info.item[field.InternalName].results : null) || [];
|
|
703
|
-
for (var j = 0; j < users.length; j++) {
|
|
704
|
-
// Append the user name
|
|
705
|
-
userNames.push(users[j].Title);
|
|
706
|
-
}
|
|
707
|
-
// Set the html value
|
|
708
|
-
html_1 = userNames.join('<br />\n');
|
|
709
|
-
}
|
|
710
|
-
else {
|
|
711
|
-
// Extract the text only for single selections
|
|
712
|
-
var elUser = document.createElement("div");
|
|
713
|
-
elUser.innerHTML = html_1;
|
|
714
|
-
html_1 = elUser.innerText;
|
|
715
|
-
}
|
|
716
|
-
}
|
|
682
|
+
// Get the control display properties
|
|
683
|
+
var dispControl = renderDisplay(control.name, props);
|
|
684
|
+
// Update the properties
|
|
685
|
+
control.data = dispControl.data;
|
|
686
|
+
control.label = dispControl.label;
|
|
687
|
+
control.showTime = dispControl.showTime;
|
|
688
|
+
control.type = dispControl.type;
|
|
689
|
+
control.value = dispControl.value;
|
|
717
690
|
}
|
|
718
691
|
};
|
|
719
692
|
// Execute the rendering event
|