mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 10:23:34 +00:00
Fix typos & remove unecessary parameter
This commit is contained in:
parent
c1da5a5685
commit
e7189d2578
@ -30,6 +30,4 @@ class LifecycleManager {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = strapi => {
|
||||
return new LifecycleManager(strapi);
|
||||
};
|
||||
module.exports = () => new LifecycleManager();
|
||||
|
||||
@ -31,7 +31,7 @@ module.exports = async () => {
|
||||
strapi.db.lifecycles.register({
|
||||
model: model.uid,
|
||||
async beforeCreate(data) {
|
||||
await getService('lcoalizations').assignDefaultLocale(data);
|
||||
await getService('localizations').assignDefaultLocale(data);
|
||||
},
|
||||
async afterCreate(entry) {
|
||||
await getService('localizations').addLocalizations(entry, { model });
|
||||
@ -40,7 +40,7 @@ module.exports = async () => {
|
||||
await getService('localizations').updateNonLocalizedFields(entry, { model });
|
||||
},
|
||||
async afterDelete(entry) {
|
||||
await getService('localizations').removeEntryFromLocalizations(entry, { model });
|
||||
await getService('localizations').removeEntryFromRelatedLocalizations(entry, { model });
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@ -4,7 +4,7 @@ const {
|
||||
assignDefaultLocale,
|
||||
addLocalizations,
|
||||
updateNonLocalizedFields,
|
||||
removeEntryFromLocalizations,
|
||||
removeEntryFromRelatedLocalizations,
|
||||
} = require('../localizations');
|
||||
|
||||
const model = {
|
||||
@ -164,7 +164,7 @@ describe('localizations service', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('removeEntryFromLocalizations', () => {
|
||||
describe('removeEntryFromRelatedLocalizations', () => {
|
||||
test('Does nothing if no localizations set', async () => {
|
||||
const update = jest.fn();
|
||||
global.strapi = {
|
||||
@ -175,7 +175,7 @@ describe('localizations service', () => {
|
||||
|
||||
const entry = { id: 1, locale: 'test' };
|
||||
|
||||
await removeEntryFromLocalizations(entry, { model });
|
||||
await removeEntryFromRelatedLocalizations(entry, { model });
|
||||
|
||||
expect(update).not.toHaveBeenCalled();
|
||||
});
|
||||
@ -197,7 +197,7 @@ describe('localizations service', () => {
|
||||
],
|
||||
};
|
||||
|
||||
await removeEntryFromLocalizations(entry, { model });
|
||||
await removeEntryFromRelatedLocalizations(entry, { model });
|
||||
|
||||
expect(update).toHaveBeenCalledTimes(1);
|
||||
expect(update).toHaveBeenCalledWith(
|
||||
|
||||
@ -50,11 +50,12 @@ const updateNonLocalizedFields = async (entry, { model }) => {
|
||||
|
||||
/**
|
||||
* Remove entry from localizations & udpate realted localizations
|
||||
* This method should be used only after an entry is deleted
|
||||
* @param {Object} entry entry to remove from localizations
|
||||
* @param {Object} options
|
||||
* @param {Object} options.model corresponding model
|
||||
*/
|
||||
const removeEntryFromLocalizations = async (entry, { model }) => {
|
||||
const removeEntryFromRelatedLocalizations = async (entry, { model }) => {
|
||||
if (Array.isArray(entry.localizations)) {
|
||||
const newLocalizations = entry.localizations.filter(({ id }) => id != entry.id);
|
||||
|
||||
@ -70,5 +71,5 @@ module.exports = {
|
||||
assignDefaultLocale,
|
||||
addLocalizations,
|
||||
updateNonLocalizedFields,
|
||||
removeEntryFromLocalizations,
|
||||
removeEntryFromRelatedLocalizations,
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user