@arsedizioni/ars-utils 18.2.34 → 18.2.35
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/clipper.ui/ui/search-result-manager/search-result-manager.d.ts +7 -1
- package/esm2022/clipper.ui/ui/search-result-manager/search-result-manager.mjs +141 -132
- package/fesm2022/arsedizioni-ars-utils-clipper.ui.mjs +141 -132
- package/fesm2022/arsedizioni-ars-utils-clipper.ui.mjs.map +1 -1
- package/package.json +12 -12
|
@@ -1020,6 +1020,143 @@ class ClipperSearchResultManager extends ClipperDocumentManager {
|
|
|
1020
1020
|
}
|
|
1021
1021
|
return data;
|
|
1022
1022
|
}
|
|
1023
|
+
/**
|
|
1024
|
+
* Prepare result items
|
|
1025
|
+
* @param items : the items to process
|
|
1026
|
+
* @param params : the current search params
|
|
1027
|
+
*/
|
|
1028
|
+
prepareResultItems(items, params) {
|
|
1029
|
+
const today = startOfToday();
|
|
1030
|
+
const groupByYear = !params.sortMode ||
|
|
1031
|
+
params.sortMode === ClipperSort.DateAsc ||
|
|
1032
|
+
params.sortMode === ClipperSort.DateDesc ||
|
|
1033
|
+
params.sortMode === ClipperSort.SourceDateAsc ||
|
|
1034
|
+
params.sortMode === ClipperSort.SourceDateDesc;
|
|
1035
|
+
const groupByRelevance = params.sortMode === ClipperSort.Relevance;
|
|
1036
|
+
const groupByPopularity = params.sortMode === ClipperSort.Popularity;
|
|
1037
|
+
let group = '';
|
|
1038
|
+
items?.forEach(n => {
|
|
1039
|
+
n.documentId = n.documentId ?? n.id;
|
|
1040
|
+
this.selection?.updateCurrent(n, n.documentId);
|
|
1041
|
+
if (n.model === ClipperModel.Quesiti) {
|
|
1042
|
+
n.info = "Quesito n° " + n.number + " del " + SystemUtils.formatDate(n.date, "d MMM yyyy");
|
|
1043
|
+
}
|
|
1044
|
+
else if (n.model === ClipperModel.Scadenze ||
|
|
1045
|
+
n.model === ClipperModel.Segnalazioni) {
|
|
1046
|
+
switch (n.model) {
|
|
1047
|
+
case ClipperModel.Scadenze:
|
|
1048
|
+
n.originDescription = 'Scadenza';
|
|
1049
|
+
break;
|
|
1050
|
+
case ClipperModel.Segnalazioni:
|
|
1051
|
+
n.originDescription = 'Segnalazione';
|
|
1052
|
+
break;
|
|
1053
|
+
}
|
|
1054
|
+
if (n.expiringInfo) {
|
|
1055
|
+
let parts = n.expiringInfo.split('|');
|
|
1056
|
+
if (parts.length === 3)
|
|
1057
|
+
n.expiringDescription = parts[2];
|
|
1058
|
+
}
|
|
1059
|
+
if (n.expiringDate) {
|
|
1060
|
+
n.date = startOfDay(new Date(n.expiringDate));
|
|
1061
|
+
const d = startOfDay(subDays(n.date, 15));
|
|
1062
|
+
n.isExpiring = today <= n.date && today >= d;
|
|
1063
|
+
n.isExpired = n.date < today;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
else {
|
|
1067
|
+
if ((n.model === ClipperModel.Articoli ||
|
|
1068
|
+
n.model === ClipperModel.News) &&
|
|
1069
|
+
n.tags) {
|
|
1070
|
+
n.info = n.tags.toUpperCase().split('#').join(", ");
|
|
1071
|
+
}
|
|
1072
|
+
if (n.model !== ClipperModel.AggiornamentoNormativo &&
|
|
1073
|
+
n.model !== ClipperModel.NormativaVigente &&
|
|
1074
|
+
n.model !== ClipperModel.Juris &&
|
|
1075
|
+
n.date) {
|
|
1076
|
+
n.date = startOfDay(new Date(n.date ?? n.publishingDate));
|
|
1077
|
+
const d = startOfDay(subDays(startOfToday(), 7));
|
|
1078
|
+
n.isNew = n.date > d;
|
|
1079
|
+
}
|
|
1080
|
+
else {
|
|
1081
|
+
n.date = null;
|
|
1082
|
+
}
|
|
1083
|
+
if (n.anchors) {
|
|
1084
|
+
let anchorType = null;
|
|
1085
|
+
let anchors = [];
|
|
1086
|
+
n.anchors.forEach((a) => {
|
|
1087
|
+
if (a.type === 20)
|
|
1088
|
+
return;
|
|
1089
|
+
if (a.type !== anchorType) {
|
|
1090
|
+
if (a.type >= 3)
|
|
1091
|
+
anchors.push({ text: a.typeDescription });
|
|
1092
|
+
anchorType = a.type;
|
|
1093
|
+
}
|
|
1094
|
+
let score = a.score;
|
|
1095
|
+
if (score > 7)
|
|
1096
|
+
score -= 7;
|
|
1097
|
+
else if (score > 5)
|
|
1098
|
+
score -= 5;
|
|
1099
|
+
else if (score > 3)
|
|
1100
|
+
score -= 3;
|
|
1101
|
+
anchors.push({
|
|
1102
|
+
text: a.text,
|
|
1103
|
+
title: a.title,
|
|
1104
|
+
documentId: a.documentId,
|
|
1105
|
+
uri: a.uri,
|
|
1106
|
+
veryRelevant: score > 0.6,
|
|
1107
|
+
});
|
|
1108
|
+
});
|
|
1109
|
+
n.anchors = anchors;
|
|
1110
|
+
}
|
|
1111
|
+
if (n.validityState > 0) {
|
|
1112
|
+
n.validityDescription = 'Il documento non è più vigente';
|
|
1113
|
+
n.isExpired = true;
|
|
1114
|
+
if (n.validUntilDate) {
|
|
1115
|
+
const expiringDate = startOfDay(new Date(n.validUntilDate));
|
|
1116
|
+
if (expiringDate < today) {
|
|
1117
|
+
n.validityDescription =
|
|
1118
|
+
'Il documento non è più vigente dal ' +
|
|
1119
|
+
SystemUtils.formatDate(expiringDate) +
|
|
1120
|
+
'.';
|
|
1121
|
+
}
|
|
1122
|
+
else {
|
|
1123
|
+
n.validityDescription =
|
|
1124
|
+
'Il documento non sarà più vigente dal ' +
|
|
1125
|
+
SystemUtils.formatDate(expiringDate) +
|
|
1126
|
+
'.';
|
|
1127
|
+
n.isExpired = false;
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
if (n.expiringDate) {
|
|
1132
|
+
n.date = startOfDay(new Date(n.expiringDate));
|
|
1133
|
+
const d = startOfDay(subDays(n.date, 15));
|
|
1134
|
+
n.isExpiring = today <= n.date && today >= d;
|
|
1135
|
+
n.isExpired = n.date < today;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
if (groupByYear) {
|
|
1139
|
+
const year = SystemUtils.formatDate(n.date ?? n.publishingDate, DateFormat.LongMonthAndYear).toLowerCase();
|
|
1140
|
+
if (group !== year) {
|
|
1141
|
+
n.group = year;
|
|
1142
|
+
group = year;
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
else if (groupByRelevance) {
|
|
1146
|
+
if (group !== 'none') {
|
|
1147
|
+
n.group =
|
|
1148
|
+
'Elementi più rilevanti per la ricerca: ' + params.text;
|
|
1149
|
+
group = 'none';
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
else if (groupByPopularity) {
|
|
1153
|
+
if (group !== 'none') {
|
|
1154
|
+
n.group = 'Elementi più popolari in ordine decrescente';
|
|
1155
|
+
group = 'none';
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1023
1160
|
/**
|
|
1024
1161
|
* Prepare results
|
|
1025
1162
|
* @param data : the optional result list to prepare
|
|
@@ -1030,139 +1167,11 @@ class ClipperSearchResultManager extends ClipperDocumentManager {
|
|
|
1030
1167
|
*/
|
|
1031
1168
|
prepareResults(data, facets, months, month, date) {
|
|
1032
1169
|
if (data) {
|
|
1033
|
-
this.snapshot = data;
|
|
1034
|
-
const filterParams = this.filterParams;
|
|
1035
|
-
const today = startOfToday();
|
|
1036
|
-
const groupByYear = !filterParams.sortMode ||
|
|
1037
|
-
filterParams.sortMode === ClipperSort.DateAsc ||
|
|
1038
|
-
filterParams.sortMode === ClipperSort.DateDesc ||
|
|
1039
|
-
filterParams.sortMode === ClipperSort.SourceDateAsc ||
|
|
1040
|
-
filterParams.sortMode === ClipperSort.SourceDateDesc;
|
|
1041
|
-
const groupByRelevance = filterParams.sortMode === ClipperSort.Relevance;
|
|
1042
|
-
const groupByPopularity = filterParams.sortMode === ClipperSort.Popularity;
|
|
1043
|
-
let group = '';
|
|
1044
1170
|
this.selection?.current.clear();
|
|
1045
|
-
this.snapshot
|
|
1046
|
-
|
|
1047
|
-
this.
|
|
1048
|
-
|
|
1049
|
-
n.info = "Quesito n° " + n.number + " del " + SystemUtils.formatDate(n.date, "d MMM yyyy");
|
|
1050
|
-
}
|
|
1051
|
-
else if (n.model === ClipperModel.Scadenze ||
|
|
1052
|
-
n.model === ClipperModel.Segnalazioni) {
|
|
1053
|
-
switch (n.model) {
|
|
1054
|
-
case ClipperModel.Scadenze:
|
|
1055
|
-
n.originDescription = 'Scadenza';
|
|
1056
|
-
break;
|
|
1057
|
-
case ClipperModel.Segnalazioni:
|
|
1058
|
-
n.originDescription = 'Segnalazione';
|
|
1059
|
-
break;
|
|
1060
|
-
}
|
|
1061
|
-
if (n.expiringInfo) {
|
|
1062
|
-
let parts = n.expiringInfo.split('|');
|
|
1063
|
-
if (parts.length === 3)
|
|
1064
|
-
n.expiringDescription = parts[2];
|
|
1065
|
-
}
|
|
1066
|
-
if (n.expiringDate) {
|
|
1067
|
-
n.date = startOfDay(new Date(n.expiringDate));
|
|
1068
|
-
const d = startOfDay(subDays(n.date, 15));
|
|
1069
|
-
n.isExpiring = today <= n.date && today >= d;
|
|
1070
|
-
n.isExpired = n.date < today;
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
else {
|
|
1074
|
-
if ((n.model === ClipperModel.Articoli ||
|
|
1075
|
-
n.model === ClipperModel.News) &&
|
|
1076
|
-
n.tags) {
|
|
1077
|
-
n.info = n.tags.toUpperCase().split('#').join(", ");
|
|
1078
|
-
}
|
|
1079
|
-
if (n.model !== ClipperModel.AggiornamentoNormativo &&
|
|
1080
|
-
n.model !== ClipperModel.NormativaVigente &&
|
|
1081
|
-
n.model !== ClipperModel.Juris &&
|
|
1082
|
-
n.date) {
|
|
1083
|
-
n.date = startOfDay(new Date(n.date ?? n.publishingDate));
|
|
1084
|
-
const d = startOfDay(subDays(startOfToday(), 7));
|
|
1085
|
-
n.isNew = n.date > d;
|
|
1086
|
-
}
|
|
1087
|
-
else {
|
|
1088
|
-
n.date = null;
|
|
1089
|
-
}
|
|
1090
|
-
if (n.anchors) {
|
|
1091
|
-
let anchorType = null;
|
|
1092
|
-
let anchors = [];
|
|
1093
|
-
n.anchors.forEach((a) => {
|
|
1094
|
-
if (a.type === 20)
|
|
1095
|
-
return;
|
|
1096
|
-
if (a.type !== anchorType) {
|
|
1097
|
-
if (a.type >= 3)
|
|
1098
|
-
anchors.push({ text: a.typeDescription });
|
|
1099
|
-
anchorType = a.type;
|
|
1100
|
-
}
|
|
1101
|
-
let score = a.score;
|
|
1102
|
-
if (score > 7)
|
|
1103
|
-
score -= 7;
|
|
1104
|
-
else if (score > 5)
|
|
1105
|
-
score -= 5;
|
|
1106
|
-
else if (score > 3)
|
|
1107
|
-
score -= 3;
|
|
1108
|
-
anchors.push({
|
|
1109
|
-
text: a.text,
|
|
1110
|
-
title: a.title,
|
|
1111
|
-
documentId: a.documentId,
|
|
1112
|
-
uri: a.uri,
|
|
1113
|
-
veryRelevant: score > 0.6,
|
|
1114
|
-
});
|
|
1115
|
-
});
|
|
1116
|
-
n.anchors = anchors;
|
|
1117
|
-
}
|
|
1118
|
-
if (n.validityState > 0) {
|
|
1119
|
-
n.validityDescription = 'Il documento non è più vigente';
|
|
1120
|
-
n.isExpired = true;
|
|
1121
|
-
if (n.validUntilDate) {
|
|
1122
|
-
const expiringDate = startOfDay(new Date(n.validUntilDate));
|
|
1123
|
-
if (expiringDate < today) {
|
|
1124
|
-
n.validityDescription =
|
|
1125
|
-
'Il documento non è più vigente dal ' +
|
|
1126
|
-
SystemUtils.formatDate(expiringDate) +
|
|
1127
|
-
'.';
|
|
1128
|
-
}
|
|
1129
|
-
else {
|
|
1130
|
-
n.validityDescription =
|
|
1131
|
-
'Il documento non sarà più vigente dal ' +
|
|
1132
|
-
SystemUtils.formatDate(expiringDate) +
|
|
1133
|
-
'.';
|
|
1134
|
-
n.isExpired = false;
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
if (n.expiringDate) {
|
|
1139
|
-
n.date = startOfDay(new Date(n.expiringDate));
|
|
1140
|
-
const d = startOfDay(subDays(n.date, 15));
|
|
1141
|
-
n.isExpiring = today <= n.date && today >= d;
|
|
1142
|
-
n.isExpired = n.date < today;
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
if (groupByYear) {
|
|
1146
|
-
const year = SystemUtils.formatDate(n.date ?? n.publishingDate, DateFormat.LongMonthAndYear).toLowerCase();
|
|
1147
|
-
if (group !== year) {
|
|
1148
|
-
n.group = year;
|
|
1149
|
-
group = year;
|
|
1150
|
-
}
|
|
1151
|
-
}
|
|
1152
|
-
else if (groupByRelevance) {
|
|
1153
|
-
if (group !== 'none') {
|
|
1154
|
-
n.group =
|
|
1155
|
-
'Elementi più rilevanti per la ricerca: ' + filterParams.text;
|
|
1156
|
-
group = 'none';
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
else if (groupByPopularity) {
|
|
1160
|
-
if (group !== 'none') {
|
|
1161
|
-
n.group = 'Elementi più popolari in ordine decrescente';
|
|
1162
|
-
group = 'none';
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
});
|
|
1171
|
+
this.snapshot = data;
|
|
1172
|
+
if (this.snapshot.items) {
|
|
1173
|
+
this.prepareResultItems(this.snapshot.items, this.filterParams);
|
|
1174
|
+
}
|
|
1166
1175
|
}
|
|
1167
1176
|
if (facets || months || month) {
|
|
1168
1177
|
this.hasFacets.set(false);
|