|
16 | 16 | ContentHome.filter = null; |
17 | 17 | ContentHome.isBusy = true; |
18 | 18 | var _data = defaultInfo; |
19 | | - |
| 19 | + |
20 | 20 | // Show the top plugin info part when on home view |
21 | 21 | Buildfire.appearance.setHeaderVisibility(true); |
22 | 22 |
|
|
472 | 472 | } |
473 | 473 | }); |
474 | 474 | } |
475 | | - |
| 475 | + |
476 | 476 | Deeplink.deleteById(ContentHome.items[index].id); |
477 | 477 | Buildfire.datastore.delete(ContentHome.items[index].id, TAG_NAMES.COUPON_ITEMS, function (err, result) { |
478 | 478 | if (err) |
479 | 479 | return; |
480 | | - |
| 480 | + |
481 | 481 | PluginEvents.unregister(ContentHome.items[index].id); |
482 | 482 | //ContentHome.items.splice(_index, 1); |
483 | 483 | ContentHome.items.splice(index, 1); |
|
524 | 524 | } else { |
525 | 525 | ContentHome.data.content.selectedStatus = 'All Statuses'; |
526 | 526 | ContentHome.data.content.selectedFilter = {title: undefined, id: "All Categories"}; |
527 | | - |
| 527 | + |
528 | 528 | ContentHome.searchOptionsForItems.filter = { "$json.title": { "$regex": '/*' } }; |
529 | 529 | ContentHome.items = []; |
530 | 530 | ContentHome.searchOptionsForItems.skip = 0; |
531 | | - |
| 531 | + |
532 | 532 | ContentHome.loadMoreItems('items'); |
533 | 533 | } |
534 | 534 | } |
|
825 | 825 | } |
826 | 826 | ContentHome.busy = true; |
827 | 827 | ContentHome.isBusy = true; |
828 | | - |
| 828 | + |
829 | 829 | if (str !== 'filter') |
830 | 830 | Buildfire.datastore.search(ContentHome.searchOptionsForItems, TAG_NAMES.COUPON_ITEMS, function (err, result) { |
831 | 831 | if (err) { |
|
843 | 843 | var tmpArray = []; |
844 | 844 | var lastIndex = result.length; |
845 | 845 | result.forEach(function (res, index) { |
846 | | - |
| 846 | + |
847 | 847 | tmpArray.push({ |
848 | 848 | 'title': res.data.title, |
849 | 849 | rank: index + 1, |
|
970 | 970 | } |
971 | 971 | $csv.import(headerRow).then(function (rows) { |
972 | 972 | rows = rows.filter(function (row) { return row.title; }); |
973 | | - |
| 973 | + |
974 | 974 | if (rows && rows.length > 1) { |
975 | 975 | var categoriesList = [], columns = rows.shift(); |
976 | 976 |
|
|
979 | 979 | ContentHome.csvDataInvalid = true; |
980 | 980 | return; |
981 | 981 | } |
982 | | - |
| 982 | + |
983 | 983 | rows.map(el => categoriesList = categoriesList.concat(el.Categories.split(","))); |
984 | 984 | categoriesList = [... new Set(categoriesList)]; |
985 | | - |
| 985 | + |
986 | 986 | var sortedCategories = []; |
987 | 987 | categoriesList.map(category => { |
988 | | - var exists = rows.filter(row => |
| 988 | + var exists = rows.filter(row => |
989 | 989 | row.SelectedCategories.toLowerCase().includes(category.toLowerCase())); |
990 | 990 |
|
991 | | - exists ? sortedCategories.push({ title: category, number: exists.length}) |
| 991 | + exists ? sortedCategories.push({ title: category, number: exists.length}) |
992 | 992 | : null; |
993 | 993 | }); |
994 | | - |
| 994 | + |
995 | 995 | buildfire.messaging.sendMessageToWidget({ type: "ImportCSV", importing: true }); |
996 | 996 | buildfire.messaging.sendMessageToWidget({ importCSV: 'started' }); |
997 | 997 | ContentHome.importingCSV = true; |
998 | | - |
| 998 | + |
999 | 999 | const insertCategories = (callback) => { |
1000 | 1000 | buildfire.datastore.search({ recordCount: true }, TAG_NAMES.COUPON_CATEGORIES, (err, categories) => { |
1001 | 1001 | if (err) return console.error(err); |
|
1013 | 1013 | let toUpdate = ContentHome.filters.find(el => el.id === categoryExists.id); |
1014 | 1014 | if(toUpdate) { |
1015 | 1015 | let toUpdateIndex = ContentHome.filters.indexOf(toUpdate); |
1016 | | - ContentHome.filters[toUpdateIndex].data.noOfItems = categoryExists.data.noOfItems; |
| 1016 | + ContentHome.filters[toUpdateIndex].data.noOfItems = categoryExists.data.noOfItems; |
1017 | 1017 | } |
1018 | 1018 |
|
1019 | 1019 | updatedAll--; |
|
1038 | 1038 | const saveRow = (row) => { |
1039 | 1039 | buildfire.datastore.insert(row, TAG_NAMES.COUPON_ITEMS, (err, result) => { |
1040 | 1040 | if (err) console.error("Failed saving row data", row); |
1041 | | - if (result && result.id) { |
| 1041 | + if (result && result.id) { |
1042 | 1042 | PluginEvents.register({ key: result.id, title: result.data.title }, true); |
1043 | 1043 | if (!row.deepLinkId) { |
1044 | 1044 | new Deeplink({ |
|
1108 | 1108 | }); |
1109 | 1109 | } |
1110 | 1110 |
|
1111 | | - |
| 1111 | + |
1112 | 1112 | var rank = ContentHome.data.content.rankOfLastItem || 0; |
1113 | 1113 | RankOfLastItem.setRank(rank); |
1114 | 1114 |
|
|
0 commit comments