Store content config with it’s type
This commit is contained in:
parent
6d46ac67de
commit
a3eeee9b57
|
@ -78,10 +78,9 @@ export default class Content {
|
|||
*/
|
||||
async saveConfiguration() {
|
||||
try {
|
||||
Database.insertOrUpdate({ type: 'contentconfig', $or: [{ id: this.id }, { name: this.name }] }, {
|
||||
type: 'contentconfig',
|
||||
Database.insertOrUpdate({ type: `${this.type}-config`, id: this.id }, {
|
||||
type: `${this.type}-config`,
|
||||
id: this.id,
|
||||
name: this.name,
|
||||
enabled: this.enabled,
|
||||
config: this.settings.strip().settings,
|
||||
data: this.data
|
||||
|
|
|
@ -39,6 +39,27 @@ export default class {
|
|||
return this._localContent ? this._localContent : (this._localContent = []);
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of content this content manager manages.
|
||||
*/
|
||||
static get contentType() {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of this content manager.
|
||||
*/
|
||||
static get moduleName() {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* The path used to store this content manager's content.
|
||||
*/
|
||||
static get pathId() {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Local path for content.
|
||||
* @return {String}
|
||||
|
@ -100,7 +121,7 @@ export default class {
|
|||
const directories = await FileUtils.listDirectory(this.contentPath);
|
||||
|
||||
for (let dir of directories) {
|
||||
// If content is already loaded this should resolve.
|
||||
// If content is already loaded this should resolve
|
||||
if (this.getContentByDirName(dir)) continue;
|
||||
|
||||
try {
|
||||
|
@ -185,7 +206,7 @@ export default class {
|
|||
|
||||
try {
|
||||
const id = readConfig.info.id || readConfig.info.name.toLowerCase().replace(/[^a-zA-Z0-9-]/g, '-').replace(/--/g, '-');
|
||||
const readUserConfig = await Database.find({ type: 'contentconfig', id });
|
||||
const readUserConfig = await Database.find({ type: `${this.contentType}-config`, id });
|
||||
if (readUserConfig.length) {
|
||||
userConfig.enabled = readUserConfig[0].enabled || false;
|
||||
userConfig.config = readUserConfig[0].config;
|
||||
|
|
Loading…
Reference in New Issue