Small fix for indexing products
parent
de5a01c671
commit
0972565124
|
@ -1,6 +1,7 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const common = require('../lib/common');
|
const common = require('../lib/common');
|
||||||
const { restrict, checkAccess } = require('../lib/auth');
|
const { restrict, checkAccess } = require('../lib/auth');
|
||||||
|
const { indexProducts } = require('../lib/indexing');
|
||||||
const colors = require('colors');
|
const colors = require('colors');
|
||||||
const rimraf = require('rimraf');
|
const rimraf = require('rimraf');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
@ -137,7 +138,7 @@ router.post('/admin/product/insert', restrict, checkAccess, (req, res) => {
|
||||||
let newId = newDoc.insertedIds[0];
|
let newId = newDoc.insertedIds[0];
|
||||||
|
|
||||||
// add to lunr index
|
// add to lunr index
|
||||||
common.indexProducts(req.app)
|
indexProducts(req.app)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
req.session.message = 'New product successfully created';
|
req.session.message = 'New product successfully created';
|
||||||
req.session.messageType = 'success';
|
req.session.messageType = 'success';
|
||||||
|
@ -253,7 +254,7 @@ router.post('/admin/product/update', restrict, checkAccess, (req, res) => {
|
||||||
res.redirect('/admin/product/edit/' + req.body.frmProductId);
|
res.redirect('/admin/product/edit/' + req.body.frmProductId);
|
||||||
}else{
|
}else{
|
||||||
// Update the index
|
// Update the index
|
||||||
common.indexProducts(req.app)
|
indexProducts(req.app)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
req.session.message = 'Successfully saved';
|
req.session.message = 'Successfully saved';
|
||||||
req.session.messageType = 'success';
|
req.session.messageType = 'success';
|
||||||
|
@ -283,7 +284,7 @@ router.get('/admin/product/delete/:id', restrict, checkAccess, (req, res) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove the index
|
// remove the index
|
||||||
common.indexProducts(req.app)
|
indexProducts(req.app)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// redirect home
|
// redirect home
|
||||||
req.session.message = 'Product successfully deleted';
|
req.session.message = 'Product successfully deleted';
|
||||||
|
|
Loading…
Reference in New Issue