adapt-authoring-ui 1.7.4 → 1.7.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.
|
@@ -99,49 +99,65 @@ define(function(require){
|
|
|
99
99
|
|
|
100
100
|
formatErrorString: function (errorString) {
|
|
101
101
|
const normalise = (s, delim) => s.split(delim).map(s => s.trim()).filter(Boolean)
|
|
102
|
-
const nl = count => '<br/>'.repeat(count ?? 1)
|
|
103
|
-
|
|
104
|
-
// Extract prefix messages (anything before the first component error)
|
|
105
|
-
const firstComponentIndex = errorString.search(/\S+-component\s+\S+/);
|
|
106
|
-
const prefixMessages = firstComponentIndex > 0
|
|
107
|
-
? normalise(errorString.substring(0, firstComponentIndex), ',')
|
|
108
|
-
: [];
|
|
109
|
-
const componentString = firstComponentIndex > 0
|
|
110
|
-
? errorString.substring(firstComponentIndex)
|
|
111
|
-
: errorString;
|
|
112
|
-
|
|
113
|
-
const components = normalise(componentString, ';')
|
|
114
|
-
const groups = {};
|
|
115
|
-
|
|
116
|
-
components.forEach(component => {
|
|
117
|
-
const [, type, id, errorsStr] = component.match(/^(\S+-component)\s+(\S+)\s+(.+)$/) ?? [];
|
|
118
102
|
|
|
119
|
-
|
|
120
|
-
|
|
103
|
+
// Match content type + id + errors: e.g. "contentobject abc123 /path must be..."
|
|
104
|
+
// Covers: contentobject, block, article, course, *-component, etc.
|
|
105
|
+
const contentErrorPattern = /\b(\S+)\s+([a-f0-9]{24})\s+(\/\S+.*?)(?=,\s*;\s*|,\s*$|$)/g;
|
|
106
|
+
|
|
107
|
+
const prefixMessages = [];
|
|
108
|
+
const groups = {};
|
|
109
|
+
let hasContentErrors = false;
|
|
110
|
+
|
|
111
|
+
// Extract semicolon-delimited segments
|
|
112
|
+
const segments = normalise(errorString, ';');
|
|
113
|
+
|
|
114
|
+
segments.forEach(segment => {
|
|
115
|
+
const matches = [...segment.matchAll(contentErrorPattern)];
|
|
116
|
+
if (!matches.length) {
|
|
117
|
+
// No content errors found in this segment — treat as prefix message
|
|
118
|
+
normalise(segment, ',').forEach(msg => {
|
|
119
|
+
if (msg.trim()) prefixMessages.push(msg.trim());
|
|
120
|
+
});
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
hasContentErrors = true;
|
|
124
|
+
|
|
125
|
+
// Extract any text before the first content error as prefix
|
|
126
|
+
const firstMatchStart = segment.indexOf(matches[0][0]);
|
|
127
|
+
if (firstMatchStart > 0) {
|
|
128
|
+
normalise(segment.substring(0, firstMatchStart), ',').forEach(msg => {
|
|
129
|
+
if (msg.trim()) prefixMessages.push(msg.trim());
|
|
130
|
+
});
|
|
121
131
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
|
|
133
|
+
matches.forEach(match => {
|
|
134
|
+
const [, type, id, errorsStr] = match;
|
|
135
|
+
// Split only on ", /" to avoid breaking apart value lists like "false,soft,hard"
|
|
136
|
+
const errors = errorsStr
|
|
137
|
+
.split(/,\s*(?=\/)/)
|
|
138
|
+
.map(s => s.trim())
|
|
139
|
+
.filter(Boolean)
|
|
140
|
+
.sort();
|
|
141
|
+
const signature = `${type}|${errors.join('|')}`;
|
|
142
|
+
|
|
143
|
+
if (!groups[signature]) groups[signature] = { type, errors, ids: [] };
|
|
144
|
+
groups[signature].ids.push(id);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
if (!hasContentErrors) return '';
|
|
149
|
+
|
|
150
|
+
// Group by content type
|
|
134
151
|
const byType = {};
|
|
135
152
|
Object.values(groups).forEach(group => {
|
|
136
153
|
if (!byType[group.type]) byType[group.type] = [];
|
|
137
154
|
byType[group.type].push(group);
|
|
138
155
|
});
|
|
139
|
-
|
|
156
|
+
|
|
140
157
|
// Format output
|
|
141
158
|
const output = [];
|
|
142
|
-
// Add prefix messages if any
|
|
143
159
|
if (prefixMessages.length) output.push(prefixMessages.join(', '));
|
|
144
|
-
|
|
160
|
+
|
|
145
161
|
const formatted = Object.entries(byType).map(([type, typeGroups]) => {
|
|
146
162
|
const totalCount = typeGroups.reduce((sum, g) => sum + g.ids.length, 0);
|
|
147
163
|
const subGroups = typeGroups.map(group => {
|
|
@@ -156,12 +172,11 @@ define(function(require){
|
|
|
156
172
|
},
|
|
157
173
|
|
|
158
174
|
onError: function(e) {
|
|
159
|
-
let text
|
|
175
|
+
let text = e.message
|
|
160
176
|
try {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
177
|
+
const formatted = this.formatErrorString(e.message)
|
|
178
|
+
if (formatted) text = formatted
|
|
179
|
+
} catch {}
|
|
165
180
|
Origin.Notify.alert({ type: 'error', text });
|
|
166
181
|
Origin.trigger('sidebar:resetButtons');
|
|
167
182
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adapt-authoring-ui",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.5",
|
|
4
4
|
"description": "Front-end application for the Adapt authoring tool",
|
|
5
5
|
"homepage": "https://github.com/adapt-security/adapt-authoring-ui",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"upath": "^2.0.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"adapt-authoring-adaptframework": "^1.9.
|
|
39
|
+
"adapt-authoring-adaptframework": "^1.9.4",
|
|
40
40
|
"adapt-authoring-server": "^1.2.1"
|
|
41
41
|
},
|
|
42
42
|
"peerDependenciesMeta": {
|