Compare commits

..

3 Commits

49 changed files with 144 additions and 23 deletions

View File

@ -30,9 +30,11 @@ import IdDisplay from '../common/IdDisplay'
import config from '../../../config'
import {
getModelByName,
getModelByPrefix
getModelByPrefix,
searchModelsByLabel
} from '../../../database/ObjectModels'
import InfoCircleIcon from '../../Icons/InfoCircleIcon'
import MenuIcon from '../../Icons/MenuIcon'
import { ApiServerContext } from './ApiServerContext'
import { AuthContext } from './AuthContext'
import { ElectronContext } from './ElectronContext'
@ -128,6 +130,22 @@ const SpotlightContent = ({
}
setLoading(false)
const models = searchModelsByLabel(searchQuery.trim()).map((model) => ({
type: model.name,
name: model.labelPlural,
icon: model.icon,
actions: [
{
default: true,
row: true,
icon: MenuIcon,
url: () => {
return model.url
}
}
]
}))
// If the query contains a prefix mode character, and the response is an object, wrap it in an array
if (
/[:?^]/.test(searchQuery) &&
@ -135,9 +153,9 @@ const SpotlightContent = ({
!Array.isArray(data) &&
typeof data === 'object'
) {
setListData([data])
setListData([...models, data])
} else {
setListData(data)
setListData([...models, ...data])
}
// Check if there's a pending query after this fetch completes
@ -290,7 +308,11 @@ const SpotlightContent = ({
const item = listData[0]
let type = item.type || item.objectType || inputPrefix?.type
const model = getModelByName(type)
const defaultAction = model ? getDefaultRowAction(model) : null
const defaultAction = item?.type
? getDefaultRowAction(item)
: model
? getDefaultRowAction(model)
: null
if (defaultAction) {
triggerRowAction(defaultAction, item)
}
@ -304,7 +326,11 @@ const SpotlightContent = ({
const item = listData[index]
let type = item.type || item.objectType || inputPrefix?.type
const model = getModelByName(type)
const defaultAction = model ? getDefaultRowAction(model) : null
const defaultAction = item?.type
? getDefaultRowAction(item)
: model
? getDefaultRowAction(model)
: null
if (defaultAction) {
triggerRowAction(defaultAction, item)
}
@ -447,10 +473,12 @@ const SpotlightContent = ({
<List
dataSource={listData}
renderItem={(item, index) => {
let type = item.objectType || inputPrefix?.type
let type = item.objectType || inputPrefix?.type || item?.type
const model = getModelByName(type)
const Icon = model?.icon
const rowActions = getRowActions(model)
const rowActions = item?.type
? item.actions
: getRowActions(model)
let shortcutText = ''
if (index === 0) {
shortcutText = 'ENTER'
@ -492,7 +520,9 @@ const SpotlightContent = ({
showId={false}
/>
) : null}
{item?._id ? (
<IdDisplay id={item._id} type={type} longId={false} />
) : null}
</Flex>
<Flex gap={'small'}>
{rowActions

View File

@ -213,6 +213,14 @@ export function getModelByPrefix(prefix) {
)
}
export function searchModelsByLabel(label) {
return objectModels.filter(
(meta) =>
meta.label.toLowerCase().includes(label.toLowerCase()) ||
meta.labelPlural.toLowerCase().includes(label.toLowerCase())
)
}
// Utility function to get nested object values
export const getPropertyValue = (obj, path) => {
if (!obj || !path) return undefined

View File

@ -8,6 +8,8 @@ import LockIcon from '../../components/Icons/LockIcon'
export const AppPassword = {
name: 'appPassword',
label: 'App Password',
labelPlural: 'App Passwords',
url: '/dashboard/management/apppasswords',
prefix: 'APP',
icon: AppPasswordIcon,
actions: [

View File

@ -3,6 +3,8 @@ import AuditLogIcon from '../../components/Icons/AuditLogIcon'
export const AuditLog = {
name: 'auditLog',
label: 'Audit Log',
labelPlural: 'Audit Logs',
url: '/dashboard/management/auditlogs',
prefix: 'ADL',
icon: AuditLogIcon,
actions: [],

View File

@ -8,6 +8,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const Client = {
name: 'client',
label: 'Client',
labelPlural: 'Clients',
url: '/dashboard/sales/clients',
prefix: 'CLI',
icon: ClientIcon,
actions: [

View File

@ -8,6 +8,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const Courier = {
name: 'courier',
label: 'Courier',
labelPlural: 'Couriers',
url: '/dashboard/management/couriers',
prefix: 'COR',
icon: CourierIcon,
actions: [

View File

@ -8,6 +8,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const CourierService = {
name: 'courierService',
label: 'Courier Service',
labelPlural: 'Courier Services',
url: '/dashboard/management/courierservices',
prefix: 'COS',
icon: CourierServiceIcon,
actions: [

View File

@ -8,6 +8,8 @@ import dayjs from 'dayjs'
export const DocumentJob = {
name: 'documentJob',
label: 'Document Job',
labelPlural: 'Document Jobs',
url: '/dashboard/management/documentjobs',
prefix: 'DJB',
icon: DocumentJobIcon,
actions: [

View File

@ -7,6 +7,8 @@ import XMarkIcon from '../../components/Icons/XMarkIcon'
export const DocumentPrinter = {
name: 'documentPrinter',
label: 'Document Printer',
labelPlural: 'Document Printers',
url: '/dashboard/management/documentprinters',
prefix: 'DPR',
icon: DocumentPrinterIcon,
actions: [

View File

@ -7,6 +7,8 @@ import DocumentSizeIcon from '../../components/Icons/DocumentSizeIcon'
export const DocumentSize = {
name: 'documentSize',
label: 'Document Size',
labelPlural: 'Document Sizes',
url: '/dashboard/management/documentsizes',
prefix: 'DSZ',
icon: DocumentSizeIcon,
actions: [

View File

@ -8,6 +8,8 @@ import DocumentTemplateIcon from '../../components/Icons/DocumentTemplateIcon'
export const DocumentTemplate = {
name: 'documentTemplate',
label: 'Document Template',
labelPlural: 'Document Templates',
url: '/dashboard/management/documenttemplates',
prefix: 'DTP',
icon: DocumentTemplateIcon,
actions: [

View File

@ -9,6 +9,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const Filament = {
name: 'filament',
label: 'Filament',
labelPlural: 'Filaments',
url: '/dashboard/management/filaments',
prefix: 'FIL',
icon: FilamentIcon,
actions: [

View File

@ -8,6 +8,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const FilamentSku = {
name: 'filamentSku',
label: 'Filament SKU',
labelPlural: 'Filament SKUs',
url: '/dashboard/management/filamentskus',
prefix: 'FSU',
icon: FilamentSkuIcon,
actions: [
@ -61,7 +63,6 @@ export const FilamentSku = {
`/dashboard/management/filamentskus/info?filamentSkuId=${_id}&action=delete`
}
],
url: (id) => `/dashboard/management/filamentskus/info?filamentSkuId=${id}`,
columns: [
'_reference',
'name',

View File

@ -4,6 +4,8 @@ import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
export const FilamentStock = {
name: 'filamentStock',
label: 'Filament Stock',
labelPlural: 'Filament Stocks',
url: '/dashboard/inventory/filamentstocks',
prefix: 'FLS',
icon: FilamentStockIcon,
actions: [

View File

@ -9,6 +9,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const File = {
name: 'file',
label: 'File',
labelPlural: 'Files',
url: '/dashboard/management/files',
prefix: 'FLE',
icon: FileIcon,
actions: [
@ -69,7 +71,6 @@ export const File = {
`/dashboard/management/files/info?fileId=${_id}&action=delete`
}
],
url: (id) => `/dashboard/management/files/info?fileId=${id}`,
columns: [
'_reference',
'name',

View File

@ -9,6 +9,8 @@ import EyeIcon from '../../components/Icons/EyeIcon'
export const GCodeFile = {
name: 'gcodeFile',
label: 'GCode File',
labelPlural: 'GCode Files',
url: '/dashboard/production/gcodefiles',
prefix: 'GCF',
icon: GCodeFileIcon,
actions: [

View File

@ -9,6 +9,8 @@ import OTPIcon from '../../components/Icons/OTPIcon'
export const Host = {
name: 'host',
label: 'Host',
labelPlural: 'Hosts',
url: '/dashboard/management/hosts',
prefix: 'HST',
icon: HostIcon,
actions: [

View File

@ -4,6 +4,7 @@ import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
export const Initial = {
name: 'initial',
label: 'Initial',
labelPlural: 'Initials',
prefix: 'INT',
icon: QuestionCircleIcon,
actions: [
@ -16,5 +17,4 @@ export const Initial = {
url: (_id) => `/dashboard/management/initials/info?initialId=${_id}`
}
],
url: () => `#`
}

View File

@ -9,6 +9,8 @@ import PlusIcon from '../../components/Icons/PlusIcon'
export const Invoice = {
name: 'invoice',
label: 'Invoice',
labelPlural: 'Invoices',
url: '/dashboard/finance/invoices',
prefix: 'INV',
icon: InvoiceIcon,
actions: [

View File

@ -6,6 +6,8 @@ import dayjs from 'dayjs'
export const Job = {
name: 'job',
label: 'Job',
labelPlural: 'Jobs',
url: '/dashboard/production/jobs',
prefix: 'JOB',
icon: JobIcon,
actions: [

View File

@ -9,6 +9,8 @@ import PlusIcon from '../../components/Icons/PlusIcon'
export const Listing = {
name: 'listing',
label: 'Listing',
labelPlural: 'Listings',
url: '/dashboard/sales/listings',
prefix: 'LST',
icon: ListingIcon,
actions: [

View File

@ -8,6 +8,7 @@ import BinIcon from '../../components/Icons/BinIcon'
export const ListingVarient = {
name: 'listingVarient',
label: 'Listing Varient',
labelPlural: 'Listing Varients',
prefix: 'LVR',
icon: ListingVarientIcon,
actions: [

View File

@ -10,6 +10,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const Marketplace = {
name: 'marketplace',
label: 'Marketplace',
labelPlural: 'Marketplaces',
url: '/dashboard/sales/marketplaces',
prefix: 'MKT',
icon: MarketplaceIcon,
actions: [

View File

@ -8,6 +8,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const Material = {
name: 'material',
label: 'Material',
labelPlural: 'Materials',
url: '/dashboard/management/materials',
prefix: 'MAT',
icon: MaterialIcon,
actions: [
@ -60,7 +62,6 @@ export const Material = {
`/dashboard/management/materials/info?materialId=${_id}&action=delete`
}
],
url: (id) => `/dashboard/management/materials/info?materialId=${id}`,
columns: ['_reference', 'name', 'tags', 'createdAt', 'updatedAt'],
filters: ['_id', 'name', 'tags'],
sorters: ['name', 'createdAt', 'updatedAt', '_id'],

View File

@ -4,6 +4,7 @@ import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
export const Note = {
name: 'note',
label: 'Note',
labelPlural: 'Notes',
prefix: 'NTE',
icon: NoteIcon,
actions: [

View File

@ -7,6 +7,8 @@ import XMarkIcon from '../../components/Icons/XMarkIcon'
export const NoteType = {
name: 'noteType',
label: 'Note Type',
labelPlural: 'Note Types',
url: '/dashboard/management/notetypes',
prefix: 'NTY',
icon: NoteTypeIcon,
actions: [

View File

@ -8,6 +8,8 @@ import XMarkIcon from '../../components/Icons/XMarkIcon'
export const OrderItem = {
name: 'orderItem',
label: 'Order Item',
labelPlural: 'Order Items',
url: '/dashboard/inventory/orderitems',
prefix: 'ODI',
icon: OrderItemIcon,
actions: [

View File

@ -8,6 +8,8 @@ import PlusIcon from '../../components/Icons/PlusIcon'
export const Part = {
name: 'part',
label: 'Part',
labelPlural: 'Parts',
url: '/dashboard/management/parts',
prefix: 'PRT',
icon: PartIcon,
actions: [

View File

@ -8,6 +8,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const PartSku = {
name: 'partSku',
label: 'Part SKU',
labelPlural: 'Part SKUs',
url: '/dashboard/management/partskus',
prefix: 'PSU',
icon: PartSkuIcon,
actions: [
@ -60,7 +62,6 @@ export const PartSku = {
`/dashboard/management/partskus/info?partSkuId=${_id}&action=delete`
}
],
url: (id) => `/dashboard/management/partskus/info?partSkuId=${id}`,
columns: [
'_reference',
'name',

View File

@ -4,6 +4,8 @@ import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
export const PartStock = {
name: 'partStock',
label: 'Part Stock',
labelPlural: 'Part Stocks',
url: '/dashboard/inventory/partstocks',
prefix: 'PTS',
icon: PartStockIcon,
actions: [
@ -16,7 +18,6 @@ export const PartStock = {
url: (_id) => `/dashboard/inventory/partstocks/info?partStockId=${_id}`
}
],
url: (id) => `/dashboard/inventory/partstocks/info?partStockId=${id}`,
filters: ['_id', 'partSku', 'startingQuantity', 'currentQuantity'],
sorters: ['partSku', 'startingQuantity', 'currentQuantity'],
columns: [

View File

@ -8,6 +8,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const Payment = {
name: 'payment',
label: 'Payment',
labelPlural: 'Payments',
url: '/dashboard/finance/payments',
prefix: 'PAY',
icon: PaymentIcon,
actions: [

View File

@ -14,6 +14,8 @@ import JobIcon from '../../components/Icons/JobIcon'
export const Printer = {
name: 'printer',
label: 'Printer',
labelPlural: 'Printers',
url: '/dashboard/production/printers',
prefix: 'PRN',
icon: PrinterIcon,
actions: [

View File

@ -8,6 +8,8 @@ import PlusIcon from '../../components/Icons/PlusIcon'
export const Product = {
name: 'product',
label: 'Product',
labelPlural: 'Products',
url: '/dashboard/management/products',
prefix: 'PRD',
icon: ProductIcon,
actions: [

View File

@ -8,6 +8,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const ProductCategory = {
name: 'productCategory',
label: 'Product Category',
labelPlural: 'Product Categories',
url: '/dashboard/management/productcategories',
prefix: 'PCG',
endpoint: 'productcategories',
icon: ProductCategoryIcon,
@ -62,8 +64,6 @@ export const ProductCategory = {
`/dashboard/management/productcategories/info?productCategoryId=${_id}&action=delete`
}
],
url: (id) =>
`/dashboard/management/productcategories/info?productCategoryId=${id}`,
columns: ['_reference', 'name', 'createdAt', 'updatedAt'],
filters: ['_id', 'name'],
sorters: ['name', 'createdAt', 'updatedAt', '_id'],

View File

@ -8,6 +8,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const ProductSku = {
name: 'productSku',
label: 'Product SKU',
labelPlural: 'Product SKUs',
url: '/dashboard/management/productskus',
prefix: 'SKU',
icon: ProductSkuIcon,
actions: [
@ -60,7 +62,6 @@ export const ProductSku = {
`/dashboard/management/productskus/info?productSkuId=${_id}&action=delete`
}
],
url: (id) => `/dashboard/management/productskus/info?productSkuId=${id}`,
columns: [
'_reference',
'name',

View File

@ -8,6 +8,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const ProductStock = {
name: 'productStock',
label: 'Product Stock',
labelPlural: 'Product Stocks',
url: '/dashboard/inventory/productstocks',
prefix: 'PDS',
icon: ProductStockIcon,
actions: [
@ -84,7 +86,6 @@ export const ProductStock = {
}
}
],
url: (id) => `/dashboard/inventory/productstocks/info?productStockId=${id}`,
filters: ['_id', 'productSku', 'currentQuantity'],
sorters: ['productSku', 'currentQuantity'],
columns: [

View File

@ -9,6 +9,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const PurchaseOrder = {
name: 'purchaseOrder',
label: 'Purchase Order',
labelPlural: 'Purchase Orders',
url: '/dashboard/inventory/purchaseorders',
prefix: 'POR',
icon: PurchaseOrderIcon,
actions: [

View File

@ -9,6 +9,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const SalesOrder = {
name: 'salesOrder',
label: 'Sales Order',
labelPlural: 'Sales Orders',
url: '/dashboard/sales/salesorders',
prefix: 'SOR',
icon: SalesOrderIcon,
actions: [

View File

@ -8,6 +8,8 @@ import XMarkIcon from '../../components/Icons/XMarkIcon'
export const Shipment = {
name: 'shipment',
label: 'Shipment',
labelPlural: 'Shipments',
url: '/dashboard/inventory/shipments',
prefix: 'SHP',
icon: ShipmentIcon,
actions: [

View File

@ -4,6 +4,7 @@ import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
export const Spool = {
name: 'spool',
label: 'Spool',
labelPlural: 'Spools',
prefix: 'SPL',
icon: FilamentIcon,
actions: [
@ -16,5 +17,4 @@ export const Spool = {
url: (_id) => `/dashboard/inventory/spool/info?spoolId=${_id}`
}
],
url: (id) => `/dashboard/inventory/spool/info?spoolId=${id}`
}

View File

@ -4,6 +4,8 @@ import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
export const StockAudit = {
name: 'stockAudit',
label: 'Stock Audit',
labelPlural: 'Stock Audits',
url: '/dashboard/inventory/stockaudits',
prefix: 'SAU',
icon: StockAuditIcon,
actions: [
@ -16,7 +18,6 @@ export const StockAudit = {
url: (_id) => `/dashboard/inventory/stockaudits/info?stockAuditId=${_id}`
}
],
url: (id) => `/dashboard/inventory/stockaudits/info?stockAuditId=${id}`,
columns: ['_reference', 'state', 'createdAt', 'updatedAt'],
filters: ['_id'],
sorters: ['createdAt', 'updatedAt'],

View File

@ -3,6 +3,8 @@ import StockEventIcon from '../../components/Icons/StockEventIcon'
export const StockEvent = {
name: 'stockEvent',
label: 'Stock Event',
labelPlural: 'Stock Events',
url: '/dashboard/inventory/stockevents',
prefix: 'SEV',
icon: StockEventIcon,
actions: [],

View File

@ -4,6 +4,8 @@ import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
export const StockLocation = {
name: 'stockLocation',
label: 'Stock Location',
labelPlural: 'Stock Locations',
url: '/dashboard/inventory/stocklocations',
prefix: 'SLN',
icon: StockLocationIcon,
actions: [
@ -17,7 +19,6 @@ export const StockLocation = {
`/dashboard/inventory/stocklocations/info?stockLocationId=${_id}`
}
],
url: (id) => `/dashboard/inventory/stocklocations/info?stockLocationId=${id}`,
filters: ['_id', 'name'],
sorters: ['name', 'createdAt'],
columns: ['_reference', 'name', 'address', 'createdAt', 'updatedAt'],

View File

@ -8,6 +8,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const StockTransfer = {
name: 'stockTransfer',
label: 'Stock Transfer',
labelPlural: 'Stock Transfers',
url: '/dashboard/inventory/stocktransfers',
prefix: 'STT',
icon: StockTransferIcon,
actions: [
@ -84,10 +86,16 @@ export const StockTransfer = {
}
}
],
url: (id) => `/dashboard/inventory/stocktransfers/info?stockTransferId=${id}`,
filters: ['_id', 'name', 'state'],
sorters: ['name', 'createdAt', 'postedAt'],
columns: ['_reference', 'name', 'state', 'postedAt', 'createdAt', 'updatedAt'],
columns: [
'_reference',
'name',
'state',
'postedAt',
'createdAt',
'updatedAt'
],
properties: [
{
name: '_id',

View File

@ -6,6 +6,8 @@ import dayjs from 'dayjs'
export const SubJob = {
name: 'subJob',
label: 'Sub Job',
labelPlural: 'Sub Jobs',
url: '/dashboard/production/subjobs',
prefix: 'SJB',
icon: SubJobIcon,
actions: [

View File

@ -8,6 +8,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const TaxRate = {
name: 'taxRate',
label: 'Tax Rate',
labelPlural: 'Tax Rates',
url: '/dashboard/management/taxrates',
prefix: 'TXR',
icon: TaxRateIcon,
actions: [

View File

@ -8,6 +8,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const TaxRecord = {
name: 'taxRecord',
label: 'Tax Record',
labelPlural: 'Tax Records',
url: '/dashboard/finance/taxrecords',
prefix: 'TXR',
icon: TaxRecordIcon,
actions: [

View File

@ -6,6 +6,8 @@ import PlusIcon from '../../components/Icons/PlusIcon'
export const User = {
name: 'user',
label: 'User',
labelPlural: 'Users',
url: '/dashboard/management/users',
prefix: 'USR',
icon: PersonIcon,
actions: [

View File

@ -8,6 +8,8 @@ import BinIcon from '../../components/Icons/BinIcon'
export const Vendor = {
name: 'vendor',
label: 'Vendor',
labelPlural: 'Vendors',
url: '/dashboard/management/vendors',
prefix: 'VEN',
icon: VendorIcon,
actions: [