Skip to content

Commit

Permalink
clean dir names
Browse files Browse the repository at this point in the history
  • Loading branch information
Xziy committed Sep 4, 2024
1 parent 0db0537 commit aec0c89
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 23 deletions.
13 changes: 5 additions & 8 deletions hook/bindAdminpanel.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = bindAdminpanel;
const settings_1 = __importDefault(require("../libs/adminpanel/model/settings"));
const CatalogHandler_1 = require("sails-adminpanel/lib/catalog/CatalogHandler");
const ProductCatalog_1 = require("../libs/adminpanel/ProductCatalog/ProductCatalog");
const productCatalog = new ProductCatalog_1.ProductCatalog();
CatalogHandler_1.CatalogHandler.add(productCatalog);
function bindAdminpanel() {
sails.on('Adminpanel:afterHook:loaded', async () => {
processBindAdminpanel();
console.log(111333);
const CatalogHandler = sails.hooks.adminpanel.getCatalogHandler();
const productCatalog = new ProductCatalog_1.ProductCatalog();
CatalogHandler.add(productCatalog);
});
}
function processBindAdminpanel() {
if (sails.hooks?.adminpanel?.addModelConfig !== undefined) {
const addModelConfig = sails.hooks.adminpanel.addModelConfig;
addModelConfig(settings_1.default);
addModelConfig(settings);
}
if (Array.isArray(sails.config.adminpanel?.sections)) {
let baseRoute = sails.config.adminpanel.routePrefix;
Expand Down
13 changes: 6 additions & 7 deletions hook/bindAdminpanel.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import settings from "../libs/adminpanel/model/settings"

import { CatalogHandler } from "sails-adminpanel/lib/catalog/CatalogHandler"
import models from "../libs/adminpanel/models/bind"
import { ProductCatalog } from "../libs/adminpanel/ProductCatalog/ProductCatalog";


const productCatalog = new ProductCatalog()
CatalogHandler.add(productCatalog);
export default function bindAdminpanel () {
sails.on('Adminpanel:afterHook:loaded', async ()=>{
processBindAdminpanel();
console.log(111333)
const CatalogHandler = sails.hooks.adminpanel.getCatalogHandler()
const productCatalog = new ProductCatalog()
CatalogHandler.add(productCatalog);
})
}

function processBindAdminpanel(){
if(sails.hooks?.adminpanel?.addModelConfig !== undefined) {
const addModelConfig = sails.hooks.adminpanel.addModelConfig;
addModelConfig(settings);
addModelConfig(models);
}

if(Array.isArray(sails.config.adminpanel?.sections)){
Expand Down
6 changes: 3 additions & 3 deletions libs/adminpanel/ProductCatalog/ProductCatalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ class BaseModelItem extends AbstractCatalog_1.AbstractItem {
concept: catalogId,
isDeleted: false
});
return records.map(record => this.toItem(record));
return records.map((record) => this.toItem(record));
}
async search(s, catalogId) {
const records = await sails.models[this.model].find({
name: { contains: s },
concept: catalogId
});
return records.map(record => this.toItem(record));
return records.map((record) => this.toItem(record));
}
updateModelItems(itemId, data, catalogId) {
return Promise.resolve(undefined);
Expand Down Expand Up @@ -117,7 +117,7 @@ class ProductCatalog extends AbstractCatalog_1.AbstractCatalog {
}
async getIdList() {
const groups = await sails.models['group'].find({});
const concepts = groups.map(group => group.concept);
const concepts = groups.map((group) => group.concept);
concepts.push('origin');
return [...new Set(concepts)];
}
Expand Down
6 changes: 3 additions & 3 deletions libs/adminpanel/ProductCatalog/ProductCatalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class BaseModelItem<T extends Item> extends AbstractItem<T> {
isDeleted: false
});

return records.map(record => this.toItem(record));
return records.map((record: ItemModel) => this.toItem(record));
}

public async search(s: string, catalogId: string): Promise<T[]> {
Expand All @@ -95,7 +95,7 @@ class BaseModelItem<T extends Item> extends AbstractItem<T> {
concept: catalogId
});

return records.map(record => this.toItem(record) as T);
return records.map((record: ItemModel) => this.toItem(record) as T);
}

updateModelItems(itemId: string | number, data: T, catalogId: string): Promise<T> {
Expand Down Expand Up @@ -141,7 +141,7 @@ export class ProductCatalog extends AbstractCatalog {

public async getIdList(): Promise<string[]> {
const groups = await sails.models['group'].find({});
const concepts: string[] = groups.map(group => group.concept);
const concepts: string[] = groups.map((group: { concept: string; }) => group.concept);
concepts.push('origin')
return [...new Set(concepts)];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ declare const _default: {
model: string;
title: string;
icon: string;
list: {};
edit: {};
};
groups: {
model: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ exports.default = {
products: {
model: 'dish',
title: 'Products',
icon: 'hamburger'
icon: 'hamburger',
list: {},
edit: {}
},
groups: {
model: 'group',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ProductConfig } from "./lib/product";

export default {
user: {
Expand All @@ -8,7 +9,10 @@ export default {
products: {
model: 'dish',
title: 'Products',
icon: 'hamburger'
icon: 'hamburger',
list: ProductConfig.list(),
edit: ProductConfig.edit(),
add: ProductConfig.add(),
},
groups: {
model: 'group',
Expand Down
4 changes: 4 additions & 0 deletions libs/adminpanel/models/lib/product.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare class ProductConfig {
static add(): {};
static edit(): {};
}
9 changes: 9 additions & 0 deletions libs/adminpanel/models/lib/product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"use strict";
class ProductConfig {
static add() {
return {};
}
static edit() {
return {};
}
}
18 changes: 18 additions & 0 deletions libs/adminpanel/models/lib/product.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { CreateUpdateConfig, FieldsModels } from "sails-adminpanel/interfaces/adminpanelConfig"

export class ProductConfig {
public fields: FieldsModels;
public static add(): CreateUpdateConfig {
return {}
}

public static edit(): CreateUpdateConfig {
return {}
}

public static list(): {fields: FieldsModels} {
return {
fields: {}
}
}
}

0 comments on commit aec0c89

Please sign in to comment.