abmp-npm 1.1.76 → 1.1.77
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/backend/daily-pull/process-member-methods.js +1 -1
- package/backend/elevated-modules.js +2 -1
- package/backend/jobs.js +2 -1
- package/backend/members-data-methods.js +9 -12
- package/backend/utils.js +15 -4
- package/package.json +1 -1
- package/pages/SaveAlerts.js +13 -0
- package/pages/SelectBannerImages.js +46 -0
- package/pages/deleteConfirm.js +19 -0
- package/pages/index.js +3 -0
|
@@ -42,7 +42,7 @@ const ensureUniqueUrl = async ({ url, memberId, fullName }) => {
|
|
|
42
42
|
excludeDropped: true,
|
|
43
43
|
excludeSearchedMember: true,
|
|
44
44
|
memberId,
|
|
45
|
-
|
|
45
|
+
normalizeSlugForComparison: true,
|
|
46
46
|
});
|
|
47
47
|
if (existingMember && existingMember.url) {
|
|
48
48
|
console.log(
|
|
@@ -11,7 +11,8 @@ const wixData = {
|
|
|
11
11
|
remove: auth.elevate(items.remove),
|
|
12
12
|
get: auth.elevate(items.get),
|
|
13
13
|
truncate: auth.elevate(items.truncate),
|
|
14
|
+
bulkSave: auth.elevate(items.bulkSave),
|
|
15
|
+
search: auth.elevate(items.search),
|
|
14
16
|
//TODO: add other methods here as needed
|
|
15
17
|
};
|
|
16
|
-
|
|
17
18
|
module.exports = { wixData };
|
package/backend/jobs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { taskManager } = require('psdev-task-manager');
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { TASKS_NAMES } = require('./tasks/consts');
|
|
4
|
+
const { TASKS } = require('./tasks/tasks-configs');
|
|
4
5
|
|
|
5
6
|
async function runScheduledTasks() {
|
|
6
7
|
try {
|
|
@@ -10,6 +10,7 @@ const {
|
|
|
10
10
|
normalizeUrlForComparison,
|
|
11
11
|
queryAllItems,
|
|
12
12
|
generateGeoHash,
|
|
13
|
+
searchAllItems,
|
|
13
14
|
} = require('./utils');
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -108,7 +109,7 @@ async function findMemberById(memberId) {
|
|
|
108
109
|
* @param {boolean} options.excludeDropped - Whether to exclude dropped members (default: true)
|
|
109
110
|
* @param {boolean} options.excludeSearchedMember - Whether to exclude a specific member (default: false)
|
|
110
111
|
* @param {string|number} [options.memberId] - Member ID to exclude when excludeSearchedMember is true (optional)
|
|
111
|
-
* @param {boolean} [options.
|
|
112
|
+
* @param {boolean} [options.normalizeSlugForComparison=false] - Whether to normalize the slug for comparison (default: false)
|
|
112
113
|
* @returns {Promise<Object|null>} - Member data or null if not found
|
|
113
114
|
*/
|
|
114
115
|
async function getMemberBySlug({
|
|
@@ -116,12 +117,12 @@ async function getMemberBySlug({
|
|
|
116
117
|
excludeDropped = true,
|
|
117
118
|
excludeSearchedMember = false,
|
|
118
119
|
memberId = null,
|
|
119
|
-
|
|
120
|
+
normalizeSlugForComparison = false,
|
|
120
121
|
}) {
|
|
121
122
|
if (!slug) return null;
|
|
122
123
|
|
|
123
124
|
try {
|
|
124
|
-
let query = wixData.
|
|
125
|
+
let query = wixData.search(COLLECTIONS.MEMBERS_DATA).expression(slug);
|
|
125
126
|
|
|
126
127
|
if (excludeDropped) {
|
|
127
128
|
query = query.ne('action', 'drop');
|
|
@@ -130,17 +131,13 @@ async function getMemberBySlug({
|
|
|
130
131
|
if (excludeSearchedMember && memberId) {
|
|
131
132
|
query = query.ne('memberId', memberId);
|
|
132
133
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
membersList = await queryAllItems(query);
|
|
137
|
-
} else {
|
|
138
|
-
membersList = await query.find().then(res => res.items);
|
|
139
|
-
}
|
|
134
|
+
query = query.limit(1000);
|
|
135
|
+
const searchResult = await searchAllItems(query);
|
|
136
|
+
const membersList = searchResult.items.filter(item => item.url && item.url.includes(slug)); //replacement for contains
|
|
140
137
|
let matchingMembers = membersList.filter(
|
|
141
138
|
item => item.url && item.url.toLowerCase() === slug.toLowerCase()
|
|
142
139
|
);
|
|
143
|
-
if (
|
|
140
|
+
if (normalizeSlugForComparison) {
|
|
144
141
|
matchingMembers = membersList
|
|
145
142
|
.filter(
|
|
146
143
|
//remove trailing "-1", "-2", etc.
|
|
@@ -152,7 +149,7 @@ async function getMemberBySlug({
|
|
|
152
149
|
const queryResultMsg = `Multiple members found with same slug ${slug} membersIds are : [${matchingMembers
|
|
153
150
|
.map(member => member.memberId)
|
|
154
151
|
.join(', ')}]`;
|
|
155
|
-
if (!
|
|
152
|
+
if (!normalizeSlugForComparison) {
|
|
156
153
|
throw new Error(queryResultMsg);
|
|
157
154
|
} else {
|
|
158
155
|
console.log(queryResultMsg);
|
package/backend/utils.js
CHANGED
|
@@ -107,18 +107,28 @@ function getAddressesByStatus(addresses = [], addressDisplayOption = []) {
|
|
|
107
107
|
})
|
|
108
108
|
.filter(Boolean);
|
|
109
109
|
}
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
let oldResults = await query.find();
|
|
110
|
+
const getAllItems = async querySearchResult => {
|
|
111
|
+
let oldResults = querySearchResult;
|
|
113
112
|
console.log(`found items: ${oldResults.items.length}`);
|
|
114
113
|
const allItems = oldResults.items;
|
|
115
114
|
while (oldResults.hasNext()) {
|
|
116
115
|
oldResults = await oldResults.next();
|
|
117
116
|
allItems.push(...oldResults.items);
|
|
118
117
|
}
|
|
119
|
-
console.log(`all items: ${allItems.length}`);
|
|
118
|
+
console.log(`all items count : ${allItems.length}`);
|
|
120
119
|
return allItems;
|
|
121
120
|
};
|
|
121
|
+
const searchAllItems = async searchQuery => {
|
|
122
|
+
console.log('start search');
|
|
123
|
+
const searchResults = await searchQuery.run();
|
|
124
|
+
return getAllItems(searchResults);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const queryAllItems = async query => {
|
|
128
|
+
console.log('start query');
|
|
129
|
+
const queryResults = await query.find();
|
|
130
|
+
return getAllItems(queryResults);
|
|
131
|
+
};
|
|
122
132
|
/**
|
|
123
133
|
* Chunks large arrays into smaller chunks for processing
|
|
124
134
|
* @param {Array} array - Array to chunk
|
|
@@ -206,4 +216,5 @@ module.exports = {
|
|
|
206
216
|
formatDateOnly,
|
|
207
217
|
getAddressesByStatus,
|
|
208
218
|
isPAC_STAFF,
|
|
219
|
+
searchAllItems,
|
|
209
220
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { lightbox } = require('@wix/site-window');
|
|
2
|
+
|
|
3
|
+
async function saveAlertsOnReady({ $w: _$w }) {
|
|
4
|
+
const receivedData = await lightbox.getContext();
|
|
5
|
+
_$w('#closeButton').onClick(() => lightbox.close());
|
|
6
|
+
_$w('#cancelButton').onClick(() => lightbox.close());
|
|
7
|
+
_$w('#leaveButton').link = receivedData?.membersExternalPortalUrl;
|
|
8
|
+
_$w('#leaveButton').target = '_blank';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
saveAlertsOnReady,
|
|
13
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const { lightbox } = require('@wix/site-window');
|
|
2
|
+
|
|
3
|
+
function selectBannerImagesOnReady({ $w: _$w }) {
|
|
4
|
+
_$w('#imageDataset').onReady(async () => {
|
|
5
|
+
const numOfItems = _$w('#imageDataset').getTotalCount();
|
|
6
|
+
const result = await _$w('#imageDataset').getItems(0, numOfItems);
|
|
7
|
+
const items = result.items;
|
|
8
|
+
console.log('Loaded items from dataset:', items);
|
|
9
|
+
|
|
10
|
+
_$w('#bannerImagesRepeater').data = items;
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
_$w('#bannerImagesRepeater').onItemReady(($item, itemData, index) => {
|
|
14
|
+
$item('#bannerImage').src = itemData.image; // image field
|
|
15
|
+
$item('#bannerSelected').checked = false;
|
|
16
|
+
|
|
17
|
+
// Only one checkbox can be selected
|
|
18
|
+
$item('#bannerSelected').onChange(() => {
|
|
19
|
+
if ($item('#bannerSelected').checked) {
|
|
20
|
+
_$w('#bannerImagesRepeater').forEachItem(($otherItem, _, otherIndex) => {
|
|
21
|
+
if (otherIndex !== index) {
|
|
22
|
+
$otherItem('#bannerSelected').checked = false;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
_$w('#uploadSelectedImages').onClick(() => {
|
|
30
|
+
let selectedImage = null;
|
|
31
|
+
|
|
32
|
+
_$w('#bannerImagesRepeater').forEachItem(($item, itemData) => {
|
|
33
|
+
if ($item('#bannerSelected').checked) {
|
|
34
|
+
selectedImage = {
|
|
35
|
+
image: itemData.image,
|
|
36
|
+
title: itemData.title,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
lightbox.close(selectedImage);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = {
|
|
45
|
+
selectBannerImagesOnReady,
|
|
46
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const { lightbox } = require('@wix/site-window');
|
|
2
|
+
|
|
3
|
+
function deleteConfirmOnReady({ $w: _$w }) {
|
|
4
|
+
_$w('#delete').onClick(() => {
|
|
5
|
+
lightbox.close({
|
|
6
|
+
toDelete: true,
|
|
7
|
+
});
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
_$w('#cancel').onClick(() => {
|
|
11
|
+
lightbox.close({
|
|
12
|
+
toDelete: false,
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
deleteConfirmOnReady,
|
|
19
|
+
};
|