ichec-angular-core 1.0.2 → 1.0.3
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.
|
@@ -350,6 +350,9 @@ class RestService {
|
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
+
function _toTitleCase(str) {
|
|
354
|
+
return str.replace(/\w\S*/g, text => text.charAt(0).toUpperCase() + text.substring(1).toLowerCase());
|
|
355
|
+
}
|
|
353
356
|
class ItemService extends RestService {
|
|
354
357
|
typenamePlural = "";
|
|
355
358
|
typename = "";
|
|
@@ -368,6 +371,9 @@ class ItemService extends RestService {
|
|
|
368
371
|
typePlural() {
|
|
369
372
|
return this.typenamePlural ? this.typenamePlural : this.typename + "s";
|
|
370
373
|
}
|
|
374
|
+
get typeTitleCase() {
|
|
375
|
+
return _toTitleCase(this.typename.replaceAll("_", ""));
|
|
376
|
+
}
|
|
371
377
|
}
|
|
372
378
|
|
|
373
379
|
class ResolvedPermission {
|
|
@@ -957,15 +963,33 @@ class DetailView {
|
|
|
957
963
|
}
|
|
958
964
|
}
|
|
959
965
|
|
|
966
|
+
class FeedbackService extends ItemWithUserService {
|
|
967
|
+
_url = Feedback.plural;
|
|
968
|
+
typename = Feedback.typename;
|
|
969
|
+
sendError(e) {
|
|
970
|
+
this.postItem({ comments: JSON.stringify(e) }).subscribe();
|
|
971
|
+
}
|
|
972
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FeedbackService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
973
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FeedbackService, providedIn: 'root' });
|
|
974
|
+
}
|
|
975
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FeedbackService, decorators: [{
|
|
976
|
+
type: Injectable,
|
|
977
|
+
args: [{
|
|
978
|
+
providedIn: 'root',
|
|
979
|
+
}]
|
|
980
|
+
}] });
|
|
981
|
+
|
|
960
982
|
class EditView {
|
|
961
983
|
createMode = signal(false, ...(ngDevMode ? [{ debugName: "createMode" }] : []));
|
|
962
984
|
heading = computed(() => { const prefix = this.createMode() ? "New " : "Edit "; return prefix + this.getTitle(); }, ...(ngDevMode ? [{ debugName: "heading" }] : []));
|
|
963
985
|
submitting = signal(false, ...(ngDevMode ? [{ debugName: "submitting" }] : []));
|
|
986
|
+
errorType = signal("", ...(ngDevMode ? [{ debugName: "errorType" }] : []));
|
|
964
987
|
item = signal(null, ...(ngDevMode ? [{ debugName: "item" }] : []));
|
|
965
988
|
fileKeys = [];
|
|
966
989
|
_route = inject(ActivatedRoute);
|
|
967
990
|
_location = inject(Location);
|
|
968
991
|
_userService = inject(UserService);
|
|
992
|
+
feedbackService = inject(FeedbackService);
|
|
969
993
|
form;
|
|
970
994
|
itemService;
|
|
971
995
|
snackBar = inject(MatSnackBar);
|
|
@@ -1028,13 +1052,23 @@ class EditView {
|
|
|
1028
1052
|
}
|
|
1029
1053
|
postItem() {
|
|
1030
1054
|
this.submitting.set(true);
|
|
1055
|
+
this.errorType.set("");
|
|
1031
1056
|
this.itemService.postItem(this.createItem()).subscribe({
|
|
1032
1057
|
next: (item) => this.saveFiles(item),
|
|
1033
1058
|
error: (e) => this.onPostError(e)
|
|
1034
1059
|
});
|
|
1035
1060
|
}
|
|
1036
1061
|
onPostError(e) {
|
|
1062
|
+
this.submitting.set(false);
|
|
1063
|
+
this.errorType.set("submit");
|
|
1064
|
+
this.feedbackService.sendError(e);
|
|
1037
1065
|
console.log(e);
|
|
1066
|
+
this.onPostErrorSnackBar(e);
|
|
1067
|
+
}
|
|
1068
|
+
onPostErrorSnackBar(_e) {
|
|
1069
|
+
this.snackBar.open("Submission failed - request support in the top right menu", "Dismiss", { verticalPosition: "top",
|
|
1070
|
+
duration: 5000
|
|
1071
|
+
});
|
|
1038
1072
|
}
|
|
1039
1073
|
putItem(item) {
|
|
1040
1074
|
this.submitting.set(true);
|
|
@@ -1044,12 +1078,20 @@ class EditView {
|
|
|
1044
1078
|
});
|
|
1045
1079
|
}
|
|
1046
1080
|
onPutError(e) {
|
|
1081
|
+
this.submitting.set(false);
|
|
1082
|
+
this.errorType.set("submit");
|
|
1083
|
+
this.feedbackService.sendError(e);
|
|
1047
1084
|
console.log(e);
|
|
1085
|
+
this.onPutErrorSnackBar(e);
|
|
1086
|
+
}
|
|
1087
|
+
onPutErrorSnackBar(_e) {
|
|
1088
|
+
this.snackBar.open("Submission failed - request support in the top right menu", "Dismiss", { verticalPosition: "top",
|
|
1089
|
+
duration: 5000
|
|
1090
|
+
});
|
|
1048
1091
|
}
|
|
1049
1092
|
saveFiles(item) {
|
|
1050
1093
|
this.item.set(item);
|
|
1051
1094
|
const next_file = this.getNextFileForUpload();
|
|
1052
|
-
console.log(next_file, this.form);
|
|
1053
1095
|
if (next_file) {
|
|
1054
1096
|
this.saveFile(item, next_file);
|
|
1055
1097
|
}
|
|
@@ -1069,22 +1111,6 @@ class EditView {
|
|
|
1069
1111
|
this.saveFiles(item);
|
|
1070
1112
|
}
|
|
1071
1113
|
}
|
|
1072
|
-
onPutFileError(e) {
|
|
1073
|
-
const item = this.item();
|
|
1074
|
-
if (item) {
|
|
1075
|
-
// Since the item is already created on the backend
|
|
1076
|
-
// switch to 'edit mode' for a file resubmit attempt
|
|
1077
|
-
this.form.setValue(item);
|
|
1078
|
-
this.createMode.set(false);
|
|
1079
|
-
}
|
|
1080
|
-
console.log(e);
|
|
1081
|
-
this.onPutFileErrorSnackbar(e);
|
|
1082
|
-
}
|
|
1083
|
-
onPutFileErrorSnackbar(_e) {
|
|
1084
|
-
this.snackBar.open("File upload failed - please try submitting again", "Dismiss", { verticalPosition: "bottom",
|
|
1085
|
-
duration: 5000
|
|
1086
|
-
});
|
|
1087
|
-
}
|
|
1088
1114
|
getNextFileForUpload() {
|
|
1089
1115
|
for (const key of this.fileKeys) {
|
|
1090
1116
|
if (!this.uploadedFiles.includes(key)) {
|
|
@@ -1093,6 +1119,21 @@ class EditView {
|
|
|
1093
1119
|
}
|
|
1094
1120
|
return null;
|
|
1095
1121
|
}
|
|
1122
|
+
onPutFileError(e) {
|
|
1123
|
+
// Since the item is already created on the backend
|
|
1124
|
+
// switch to 'edit mode' for a file resubmit attempt
|
|
1125
|
+
this.createMode.set(false);
|
|
1126
|
+
this.submitting.set(false);
|
|
1127
|
+
this.errorType.set("submit");
|
|
1128
|
+
this.feedbackService.sendError(e);
|
|
1129
|
+
console.log(e);
|
|
1130
|
+
this.onPutFileErrorSnackbar(e);
|
|
1131
|
+
}
|
|
1132
|
+
onPutFileErrorSnackbar(_e) {
|
|
1133
|
+
this.snackBar.open("File upload failed - please re-attach and try submitting again", "Dismiss", { verticalPosition: "top",
|
|
1134
|
+
duration: 5000
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1096
1137
|
isCreateRoute() {
|
|
1097
1138
|
const urls = this._route.snapshot.url;
|
|
1098
1139
|
if (!urls) {
|
|
@@ -1120,12 +1161,13 @@ class EditView {
|
|
|
1120
1161
|
}
|
|
1121
1162
|
onItemUpdated(item) {
|
|
1122
1163
|
this.submitting.set(false);
|
|
1164
|
+
this.errorType.set("");
|
|
1123
1165
|
this.uploadedFiles = [];
|
|
1124
1166
|
this.item.set(item);
|
|
1125
1167
|
this.postItemUpdated();
|
|
1126
1168
|
}
|
|
1127
1169
|
postItemUpdated() {
|
|
1128
|
-
this.snackBar.open(this.itemService.
|
|
1170
|
+
this.snackBar.open(this.itemService.typeTitleCase + " updated ok", "Dismiss", { verticalPosition: "top",
|
|
1129
1171
|
duration: 5000
|
|
1130
1172
|
});
|
|
1131
1173
|
this.goBack();
|
|
@@ -2575,19 +2617,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImpor
|
|
|
2575
2617
|
MatDividerModule], template: "<mat-sidenav-container class=\"leftnav-container\">\n @if(leftNavService.wide()){\n <mat-sidenav mode=\"side\" class=\"leftnav-side\" [opened]=\"user()!== null\" style=\"width:200px; padding-top:0px\">\n <mat-nav-list>\n @for (grouping of leftNavService.activeGroupings(); track grouping; let idx=$index; let count=$count) { \n <ul>\n @if(grouping.name)\n {\n <div style=\"display:flex; width: 100%; align-items: center; text-align: center;margin-top: 5px; margin-bottom: 5px;\">\n <span style=\"width:100%\">{{grouping.name}}</span>\n </div>\n }\n @for (option of grouping.options; track option) {\n <li>\n <a mat-list-item \n [routerLink]=\"option.route\" \n routerLinkActive #rla=\"routerLinkActive\" \n [activated]=\"rla.isActive\">\n <div style=\"display:flex; vertical-align:middle;\">\n <mat-icon style=\"margin-right: 5px;\">{{option.icon}}</mat-icon><span>{{ option.name }}</span>\n </div>\n </a>\n </li>\n }\n @if(idx < count-1)\n {\n <mat-divider></mat-divider>\n }\n </ul>\n }\n </mat-nav-list>\n </mat-sidenav>\n }\n @else{\n <mat-sidenav mode=\"side\" class=\"leftnav-side\" [opened]=\"user()!== null\" style=\"width: 70px;\">\n <mat-nav-list>\n @for (grouping of leftNavService.activeGroupings(); track grouping; let idx=$index; let count=$count) { \n <ul>\n @if(grouping.name)\n {\n <div style=\"display:flex; width: 100%; flex-direction: row; align-items: center; text-align: center;margin-top: 5px; margin-bottom: 5px;\">\n <span style=\"width:100%\">{{grouping.name}}</span>\n </div>\n }\n @for (option of grouping.options; track option) {\n <li>\n <a mat-list-item \n [routerLink]=\"option.route\" \n routerLinkActive #rla=\"routerLinkActive\" \n [activated]=\"rla.isActive\" matTooltip=\"{{option.name}}\">\n <div style=\"display:flex; vertical-align:middle;\">\n <mat-icon>{{option.icon}}</mat-icon>\n </div>\n </a>\n </li>\n }\n @if(idx < count-1)\n {\n <mat-divider></mat-divider>\n }\n </ul>\n }\n </mat-nav-list>\n </mat-sidenav>\n }\n\n <mat-sidenav-content class=\"leftnav-content\" [style.background-image]=\"backgroundStyle\"> \n <router-outlet />\n </mat-sidenav-content>\n</mat-sidenav-container>\n", styles: [":host{display:flex;flex-direction:column}.leftnav-container{flex-grow:1;display:flex}.leftnav-content{display:flex;flex-grow:1;height:90vh;background-blend-mode:lighten;background-color:#ffffffa6;background-size:cover}.leftnav-side{padding:5px}ul,li{margin:0;padding:0;list-style-type:none;padding-inline-start:0;list-style:none}\n"] }]
|
|
2576
2618
|
}], ctorParameters: () => [], propDecorators: { background: [{ type: i0.Input, args: [{ isSignal: true, alias: "background", required: false }] }], sideNavContent: [{ type: i0.ViewChild, args: [i0.forwardRef(() => MatSidenavContent), { isSignal: true }] }] } });
|
|
2577
2619
|
|
|
2578
|
-
class FeedbackService extends ItemWithUserService {
|
|
2579
|
-
_url = Feedback.plural;
|
|
2580
|
-
typename = Feedback.typename;
|
|
2581
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FeedbackService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
2582
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FeedbackService, providedIn: 'root' });
|
|
2583
|
-
}
|
|
2584
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: FeedbackService, decorators: [{
|
|
2585
|
-
type: Injectable,
|
|
2586
|
-
args: [{
|
|
2587
|
-
providedIn: 'root',
|
|
2588
|
-
}]
|
|
2589
|
-
}] });
|
|
2590
|
-
|
|
2591
2620
|
class FeedbackForm {
|
|
2592
2621
|
fb = inject(FormBuilder);
|
|
2593
2622
|
form;
|