forked from tsai/budibase
90 changed files with 5991 additions and 2082 deletions
File diff suppressed because one or more lines are too long
@ -1 +1,4 @@ |
|||||
/*export { app } from "./generators/appGenerator";*/ |
export { forms } from "./generators/formsGenerator"; |
||||
|
export { indexTables } from "./generators/indexTablesGenerator"; |
||||
|
export { app } from "./generators/appGenerator"; |
||||
|
export { recordHomePageComponents as recordHomepages } from "./generators/recordHomePageGenerator"; |
||||
@ -0,0 +1,36 @@ |
|||||
|
import { navContentComponentName, selectNavContent } from "./selectedNavContentGenerator"; |
||||
|
import { recordHomepages } from "./recordHomePageGenerator"; |
||||
|
export const app = ({records, indexes, helpers}) => [ |
||||
|
{ |
||||
|
name: "Application Root", |
||||
|
inherits: "@budibase/bootstrap-components/nav", |
||||
|
props: { |
||||
|
items: recordHomepages({indexes, records}) |
||||
|
.map(navItem), |
||||
|
orientation: "horizontal", |
||||
|
alignment: "start", |
||||
|
fill: false, |
||||
|
pills: true, |
||||
|
selectedItem: { |
||||
|
"##bbstate":"selectedNav", |
||||
|
"##bbstatefallback":`${records[0].name}`, |
||||
|
"##bbsource": "store" |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
name: "Login", |
||||
|
inherits: "@budibase/standard-components/login", |
||||
|
props: {} |
||||
|
}, |
||||
|
...selectNavContent({records, indexes, helpers}) |
||||
|
] |
||||
|
|
||||
|
|
||||
|
export const navItem = ({record}) => ({ |
||||
|
title: record.collectionName, |
||||
|
component : { |
||||
|
_component: navContentComponentName(record) |
||||
|
} |
||||
|
}) |
||||
|
|
||||
@ -1,27 +0,0 @@ |
|||||
import {indexTables, getIndexTableName} from "./indexTablesGenerator"; |
|
||||
|
|
||||
export const nav = ({records, indexes, helpers}) => [ |
|
||||
{ |
|
||||
name: "Application Root", |
|
||||
inherits: "@budibase/bootstrap-components/nav", |
|
||||
props: { |
|
||||
items: indexes |
|
||||
.filter(i => i.parent().type === "root") |
|
||||
.map(navItem), |
|
||||
orientation: "horizontal", |
|
||||
alignment: "center", |
|
||||
fill: true, |
|
||||
pills: false |
|
||||
} |
|
||||
}, |
|
||||
...indexTables({records, indexes, helpers}) |
|
||||
] |
|
||||
|
|
||||
|
|
||||
export const navItem = (index) => ({ |
|
||||
title: index.name, |
|
||||
component : { |
|
||||
_component: getIndexTableName(index) |
|
||||
} |
|
||||
}) |
|
||||
|
|
||||
@ -0,0 +1,133 @@ |
|||||
|
import { |
||||
|
getIndexTableName, indexTables |
||||
|
} from "./indexTablesGenerator"; |
||||
|
|
||||
|
import { |
||||
|
buttons |
||||
|
} from "./buttonGenerators"; |
||||
|
|
||||
|
export const recordHomePageComponents = ({indexes, records, helpers}) => |
||||
|
[ |
||||
|
...recordHomepages({indexes, records}) |
||||
|
.map(component), |
||||
|
|
||||
|
...recordHomepages({indexes, records}) |
||||
|
.map(homePageButtons), |
||||
|
|
||||
|
...indexTables({indexes, records, helpers}), |
||||
|
|
||||
|
...buttons({indexes, buttons, helpers}) |
||||
|
] |
||||
|
|
||||
|
|
||||
|
const findIndexForRecord = (indexes, record) => { |
||||
|
const forRecord = indexes.filter(i => i.allowedRecordNodeIds.includes(record.nodeId)); |
||||
|
if(forRecord.length === 0) return; |
||||
|
if(forRecord.length === 1) return forRecord[0]; |
||||
|
const noMap = forRecord.filter(i => !i.filter || !i.filter.trim()); |
||||
|
if(noMap.length === 0) forRecord[0]; |
||||
|
return noMap[0]; |
||||
|
} |
||||
|
|
||||
|
export const recordHomepages = ({indexes, records}) => |
||||
|
records.filter(r => r.parent().type === "root") |
||||
|
.map(r =>({ |
||||
|
record:r, |
||||
|
index:findIndexForRecord(indexes, r) |
||||
|
})) |
||||
|
.filter(r => r.index); |
||||
|
|
||||
|
|
||||
|
export const homepageComponentName = (record) => |
||||
|
`${record.name}/${record.name} homepage`; |
||||
|
|
||||
|
const component = ({record, index}) => ({ |
||||
|
inherits: "@budibase/standard-components/div", |
||||
|
name: homepageComponentName(record), |
||||
|
props: { |
||||
|
className: "p-3", |
||||
|
children: [ |
||||
|
{ |
||||
|
component: { |
||||
|
_component: "@budibase/standard-components/h2", |
||||
|
text: record.collectionName |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
component: { |
||||
|
_component: `${record.name}/homepage buttons`, |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
component: { |
||||
|
_component: getIndexTableName(index) |
||||
|
} |
||||
|
} |
||||
|
], |
||||
|
onLoad: [ |
||||
|
{ |
||||
|
"##eventHandlerType": "Set State", |
||||
|
parameters: { |
||||
|
path: `isEditing${record.name}`, |
||||
|
value: "" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"##eventHandlerType": "List Records", |
||||
|
parameters: { |
||||
|
statePath: index.nodeKey(), |
||||
|
indexKey: index.nodeKey() |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
|
||||
|
}); |
||||
|
|
||||
|
const homePageButtons = ({index, record}) => ({ |
||||
|
inherits: "@budibase/standard-components/div", |
||||
|
name: `${record.name}/homepage buttons`, |
||||
|
props: { |
||||
|
className: "btn-group", |
||||
|
children: [ |
||||
|
{ |
||||
|
component: { |
||||
|
_component: "common/Default Button", |
||||
|
contentText: `Create ${record.name}`, |
||||
|
onClick: [ |
||||
|
{ |
||||
|
"##eventHandlerType": "Get New Record", |
||||
|
parameters: { |
||||
|
statePath: record.name, |
||||
|
collectionKey: `/${record.collectionName}`, |
||||
|
childRecordType: record.name |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"##eventHandlerType": "Set State", |
||||
|
parameters: { |
||||
|
path: `isEditing${record.name}`, |
||||
|
value: "true" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
component: { |
||||
|
_component: "common/Default Button", |
||||
|
contentText: `Refresh`, |
||||
|
onClick: [ |
||||
|
{ |
||||
|
"##eventHandlerType": "List Records", |
||||
|
parameters: { |
||||
|
statePath: index.nodeKey(), |
||||
|
indexKey: index.nodeKey() |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
}) |
||||
@ -1,39 +0,0 @@ |
|||||
import {getIndexTableName} from "./indexTablesGenerator"; |
|
||||
|
|
||||
export const rootContent = ({indexes, records, helpers}) => |
|
||||
record.filter(r => r.parent().type === "root") |
|
||||
.map(r =>({ |
|
||||
record, |
|
||||
index:findIndexForRecord(indexes, r) |
|
||||
})) |
|
||||
.filter(r => r.index) |
|
||||
.map(component) |
|
||||
|
|
||||
|
|
||||
const findIndexForRecord = (indexes, record) => { |
|
||||
const forRecord = indexes.filter(i => i.allowedRecordNodeIds.includes(record.nodeId)); |
|
||||
if(forRecord.length === 0) return; |
|
||||
if(forRecord.length === 1) return forRecord[0]; |
|
||||
const noMap = forRecord.filter(i => !i.filter || !i.filter.trim()); |
|
||||
if(noMap.length === 0) forRecord[0]; |
|
||||
return noMap[0]; |
|
||||
} |
|
||||
|
|
||||
const component = (recordAndIndex) => ({ |
|
||||
_component: "@budibase/standard-components/div", |
|
||||
className: "p-3", |
|
||||
children: [ |
|
||||
{ |
|
||||
component: { |
|
||||
_component: "@budibase/standard-components/H2", |
|
||||
text: recordAndIndex.record.collectionName |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
component: { |
|
||||
_component: getIndexTableName(recordAndIndex.index) |
|
||||
} |
|
||||
} |
|
||||
] |
|
||||
|
|
||||
}) |
|
||||
@ -0,0 +1,36 @@ |
|||||
|
import { |
||||
|
recordHomepages, |
||||
|
homepageComponentName, |
||||
|
recordHomePageComponents |
||||
|
} from "./recordHomePageGenerator"; |
||||
|
import { formName, forms } from "./formsGenerator"; |
||||
|
|
||||
|
export const selectNavContent = ({indexes, records, helpers}) => |
||||
|
[ |
||||
|
...recordHomepages({indexes, records}) |
||||
|
.map(component), |
||||
|
|
||||
|
...recordHomePageComponents({indexes, records, helpers}), |
||||
|
|
||||
|
...forms({indexes, records, helpers}) |
||||
|
|
||||
|
] |
||||
|
|
||||
|
|
||||
|
export const navContentComponentName = record => |
||||
|
`${record.name}/${record.name} Nav Content`; |
||||
|
|
||||
|
const component = ({record, index}) => ({ |
||||
|
inherits: "@budibase/standard-components/if", |
||||
|
description: `the component that gets displayed when the ${record.collectionName} nav is selected`, |
||||
|
name: navContentComponentName(record), |
||||
|
props: { |
||||
|
condition: `$store.isEditing${record.name}`, |
||||
|
thenComponent: { |
||||
|
_component: formName(record) |
||||
|
}, |
||||
|
elseComponent: { |
||||
|
_component: homepageComponentName(record) |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
@ -1,2 +1,3 @@ |
|||||
/*export {default as button} from "./Button.svelte";*/ |
export {default as form} from "./Form.svelte"; |
||||
|
export {default as nav} from "./Nav.svelte"; |
||||
|
|
||||
|
|||||
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
@ -0,0 +1,29 @@ |
|||||
|
{ |
||||
|
"name": "Application Root", |
||||
|
"inherits": "@budibase/bootstrap-components/nav", |
||||
|
"props": { |
||||
|
"items": [ |
||||
|
{ |
||||
|
"title": "customers", |
||||
|
"component": { |
||||
|
"_component": "customer/customer Nav Content" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"title": "contacts", |
||||
|
"component": { |
||||
|
"_component": "Contact/Contact Nav Content" |
||||
|
} |
||||
|
} |
||||
|
], |
||||
|
"orientation": "horizontal", |
||||
|
"alignment": "start", |
||||
|
"fill": false, |
||||
|
"pills": true, |
||||
|
"selectedItem": { |
||||
|
"##bbstate": "selectedNav", |
||||
|
"##bbstatefallback": "customer", |
||||
|
"##bbsource": "store" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,107 @@ |
|||||
|
{ |
||||
|
"name": "Contact/Contact Form", |
||||
|
"description": "Control for creating/updating '/contacts/3-{id}' ", |
||||
|
"inherits": "@budibase/standard-components/div", |
||||
|
"props": { |
||||
|
"className": "p-1", |
||||
|
"children": [ |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "@budibase/standard-components/h3", |
||||
|
"text": "Edit Contact" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "@budibase/standard-components/form", |
||||
|
"formControls": [ |
||||
|
{ |
||||
|
"control": { |
||||
|
"_component": "@budibase/standard-components/input", |
||||
|
"value": { |
||||
|
"##bbstate": "Contact.name", |
||||
|
"##bbsource": "store" |
||||
|
}, |
||||
|
"className": "form-control", |
||||
|
"type": "text" |
||||
|
}, |
||||
|
"label": "Name" |
||||
|
}, |
||||
|
{ |
||||
|
"control": { |
||||
|
"_component": "@budibase/standard-components/input", |
||||
|
"value": { |
||||
|
"##bbstate": "Contact.contacted", |
||||
|
"##bbsource": "store" |
||||
|
}, |
||||
|
"className": "form-control", |
||||
|
"type": "text" |
||||
|
}, |
||||
|
"label": "Has Been Contacted" |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "@budibase/standard-components/stackpanel", |
||||
|
"direction": "horizontal", |
||||
|
"children": [ |
||||
|
{ |
||||
|
"control": { |
||||
|
"_component": "@budibase/standard-components/div", |
||||
|
"className": "btn-group", |
||||
|
"children": [ |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "common/Primary Button", |
||||
|
"contentText": "Save Contact", |
||||
|
"onClick": [ |
||||
|
{ |
||||
|
"##eventHandlerType": "Save Record", |
||||
|
"parameters": { |
||||
|
"statePath": "Contact" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"##eventHandlerType": "Set State", |
||||
|
"parameters": { |
||||
|
"path": "isEditingContact", |
||||
|
"value": "" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"control": { |
||||
|
"_component": "@budibase/standard-components/div", |
||||
|
"className": "btn-group", |
||||
|
"children": [ |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "common/Default Button", |
||||
|
"contentText": "Cancel", |
||||
|
"onClick": [ |
||||
|
{ |
||||
|
"##eventHandlerType": "Set State", |
||||
|
"parameters": { |
||||
|
"path": "isEditingContact", |
||||
|
"value": "" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
{ |
||||
|
"inherits": "@budibase/standard-components/if", |
||||
|
"description": "the component that gets displayed when the contacts nav is selected", |
||||
|
"name": "Contact/Contact Nav Content", |
||||
|
"props": { |
||||
|
"condition": "$store.isEditingContact", |
||||
|
"thenComponent": { |
||||
|
"_component": "Contact/Contact Form" |
||||
|
}, |
||||
|
"elseComponent": { |
||||
|
"_component": "Contact/Contact homepage" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
{ |
||||
|
"inherits": "@budibase/standard-components/div", |
||||
|
"name": "Contact/Contact homepage", |
||||
|
"props": { |
||||
|
"className": "p-3", |
||||
|
"children": [ |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "@budibase/standard-components/h2", |
||||
|
"text": "contacts" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "Contact/homepage buttons" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "all_contacts Table" |
||||
|
} |
||||
|
} |
||||
|
], |
||||
|
"onLoad": [ |
||||
|
{ |
||||
|
"##eventHandlerType": "Set State", |
||||
|
"parameters": { |
||||
|
"path": "isEditingContact", |
||||
|
"value": "" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"##eventHandlerType": "List Records", |
||||
|
"parameters": { |
||||
|
"statePath": "/all_contacts", |
||||
|
"indexKey": "/all_contacts" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
{ |
||||
|
"inherits": "@budibase/standard-components/div", |
||||
|
"name": "Contact/homepage buttons", |
||||
|
"props": { |
||||
|
"className": "btn-group", |
||||
|
"children": [ |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "common/Default Button", |
||||
|
"contentText": "Create Contact", |
||||
|
"onClick": [ |
||||
|
{ |
||||
|
"##eventHandlerType": "Get New Record", |
||||
|
"parameters": { |
||||
|
"statePath": "Contact", |
||||
|
"collectionKey": "/contacts", |
||||
|
"childRecordType": "Contact" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"##eventHandlerType": "Set State", |
||||
|
"parameters": { |
||||
|
"path": "isEditingContact", |
||||
|
"value": "true" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "common/Default Button", |
||||
|
"contentText": "Refresh", |
||||
|
"onClick": [ |
||||
|
{ |
||||
|
"##eventHandlerType": "List Records", |
||||
|
"parameters": { |
||||
|
"statePath": "/all_contacts", |
||||
|
"indexKey": "/all_contacts" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,5 @@ |
|||||
|
{ |
||||
|
"name": "Login", |
||||
|
"inherits": "@budibase/standard-components/login", |
||||
|
"props": {} |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
{ |
||||
|
"name": "all_contacts Table", |
||||
|
"inherits": "@budibase/standard-components/table", |
||||
|
"props": { |
||||
|
"data": { |
||||
|
"##bbstate": "/all_contacts", |
||||
|
"##bbsource": "store" |
||||
|
}, |
||||
|
"tableClass": "table table-hover", |
||||
|
"theadClass": "thead-dark", |
||||
|
"columns": [ |
||||
|
{ |
||||
|
"title": "contacted", |
||||
|
"value": { |
||||
|
"##bbstate": "contacted", |
||||
|
"##bbsource": "context" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"title": "name", |
||||
|
"value": { |
||||
|
"##bbstate": "name", |
||||
|
"##bbsource": "context" |
||||
|
} |
||||
|
} |
||||
|
], |
||||
|
"onRowClick": [ |
||||
|
{ |
||||
|
"##eventHandlerType": "Set State", |
||||
|
"parameters": { |
||||
|
"path": "currentView", |
||||
|
"value": { |
||||
|
"##bbstate": "type", |
||||
|
"##bbsource": "context" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
{ |
||||
|
"name": "all_customers Table", |
||||
|
"inherits": "@budibase/standard-components/table", |
||||
|
"props": { |
||||
|
"data": { |
||||
|
"##bbstate": "/all_customers", |
||||
|
"##bbsource": "store" |
||||
|
}, |
||||
|
"tableClass": "table table-hover", |
||||
|
"theadClass": "thead-dark", |
||||
|
"columns": [ |
||||
|
{ |
||||
|
"title": "enquiry", |
||||
|
"value": { |
||||
|
"##bbstate": "enquiry", |
||||
|
"##bbsource": "context" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"title": "name", |
||||
|
"value": { |
||||
|
"##bbstate": "name", |
||||
|
"##bbsource": "context" |
||||
|
} |
||||
|
} |
||||
|
], |
||||
|
"onRowClick": [ |
||||
|
{ |
||||
|
"##eventHandlerType": "Set State", |
||||
|
"parameters": { |
||||
|
"path": "currentView", |
||||
|
"value": { |
||||
|
"##bbstate": "type", |
||||
|
"##bbsource": "context" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"name": "common/Default Button", |
||||
|
"description": "Bootstrap default button", |
||||
|
"inherits": "@budibase/standard-components/button", |
||||
|
"props": { |
||||
|
"className": "btn btn-light" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"name": "common/Primary Button", |
||||
|
"description": "Bootstrap primary button ", |
||||
|
"inherits": "@budibase/standard-components/button", |
||||
|
"props": { |
||||
|
"className": "btn btn-primary" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,120 @@ |
|||||
|
{ |
||||
|
"name": "customer/customer Form", |
||||
|
"description": "Control for creating/updating '/customers/1-{id}' ", |
||||
|
"inherits": "@budibase/standard-components/div", |
||||
|
"props": { |
||||
|
"className": "p-1", |
||||
|
"children": [ |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "@budibase/standard-components/h3", |
||||
|
"text": "Edit customer" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "@budibase/standard-components/form", |
||||
|
"formControls": [ |
||||
|
{ |
||||
|
"control": { |
||||
|
"_component": "@budibase/standard-components/input", |
||||
|
"value": { |
||||
|
"##bbstate": "customer.name", |
||||
|
"##bbsource": "store" |
||||
|
}, |
||||
|
"className": "form-control", |
||||
|
"type": "text" |
||||
|
}, |
||||
|
"label": "Name" |
||||
|
}, |
||||
|
{ |
||||
|
"control": { |
||||
|
"_component": "@budibase/standard-components/select", |
||||
|
"options": [ |
||||
|
{ |
||||
|
"id": "Google", |
||||
|
"value": "Google" |
||||
|
}, |
||||
|
{ |
||||
|
"id": "Facebook", |
||||
|
"value": "Facebook" |
||||
|
}, |
||||
|
{ |
||||
|
"id": "Word of Mouth", |
||||
|
"value": "Word of Mouth" |
||||
|
} |
||||
|
], |
||||
|
"value": { |
||||
|
"##bbstate": "customer.enquiry", |
||||
|
"##bbsource": "store" |
||||
|
}, |
||||
|
"className": "form-control" |
||||
|
}, |
||||
|
"label": "Enquiry Source" |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "@budibase/standard-components/stackpanel", |
||||
|
"direction": "horizontal", |
||||
|
"children": [ |
||||
|
{ |
||||
|
"control": { |
||||
|
"_component": "@budibase/standard-components/div", |
||||
|
"className": "btn-group", |
||||
|
"children": [ |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "common/Primary Button", |
||||
|
"contentText": "Save customer", |
||||
|
"onClick": [ |
||||
|
{ |
||||
|
"##eventHandlerType": "Save Record", |
||||
|
"parameters": { |
||||
|
"statePath": "customer" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"##eventHandlerType": "Set State", |
||||
|
"parameters": { |
||||
|
"path": "isEditingcustomer", |
||||
|
"value": "" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"control": { |
||||
|
"_component": "@budibase/standard-components/div", |
||||
|
"className": "btn-group", |
||||
|
"children": [ |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "common/Default Button", |
||||
|
"contentText": "Cancel", |
||||
|
"onClick": [ |
||||
|
{ |
||||
|
"##eventHandlerType": "Set State", |
||||
|
"parameters": { |
||||
|
"path": "isEditingcustomer", |
||||
|
"value": "" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
{ |
||||
|
"inherits": "@budibase/standard-components/if", |
||||
|
"description": "the component that gets displayed when the customers nav is selected", |
||||
|
"name": "customer/customer Nav Content", |
||||
|
"props": { |
||||
|
"condition": "$store.isEditingcustomer", |
||||
|
"thenComponent": { |
||||
|
"_component": "customer/customer Form" |
||||
|
}, |
||||
|
"elseComponent": { |
||||
|
"_component": "customer/customer homepage" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
{ |
||||
|
"inherits": "@budibase/standard-components/div", |
||||
|
"name": "customer/customer homepage", |
||||
|
"props": { |
||||
|
"className": "p-3", |
||||
|
"children": [ |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "@budibase/standard-components/h2", |
||||
|
"text": "customers" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "customer/homepage buttons" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "all_customers Table" |
||||
|
} |
||||
|
} |
||||
|
], |
||||
|
"onLoad": [ |
||||
|
{ |
||||
|
"##eventHandlerType": "Set State", |
||||
|
"parameters": { |
||||
|
"path": "isEditingcustomer", |
||||
|
"value": "" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"##eventHandlerType": "List Records", |
||||
|
"parameters": { |
||||
|
"statePath": "/all_customers", |
||||
|
"indexKey": "/all_customers" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
{ |
||||
|
"inherits": "@budibase/standard-components/div", |
||||
|
"name": "customer/homepage buttons", |
||||
|
"props": { |
||||
|
"className": "btn-group", |
||||
|
"children": [ |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "common/Default Button", |
||||
|
"contentText": "Create customer", |
||||
|
"onClick": [ |
||||
|
{ |
||||
|
"##eventHandlerType": "Get New Record", |
||||
|
"parameters": { |
||||
|
"statePath": "customer", |
||||
|
"collectionKey": "/customers", |
||||
|
"childRecordType": "customer" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"##eventHandlerType": "Set State", |
||||
|
"parameters": { |
||||
|
"path": "isEditingcustomer", |
||||
|
"value": "true" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"component": { |
||||
|
"_component": "common/Default Button", |
||||
|
"contentText": "Refresh", |
||||
|
"onClick": [ |
||||
|
{ |
||||
|
"##eventHandlerType": "List Records", |
||||
|
"parameters": { |
||||
|
"statePath": "/all_customers", |
||||
|
"indexKey": "/all_customers" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
@ -1 +1 @@ |
|||||
window['##BUDIBASE_APPDEFINITION##'] = {"hierarchy":{"name":"root","type":"root","children":[{"name":"customer","type":"record","fields":[{"name":"name","type":"string","typeOptions":{"maxLength":null,"values":null,"allowDeclaredValuesOnly":false},"label":"Name","getInitialValue":"default","getUndefinedValue":"default"},{"name":"enquiry","type":"string","typeOptions":{"maxLength":null,"values":["Google","Facebook","Word of Mouth"],"allowDeclaredValuesOnly":true},"label":"Enquiry Source","getInitialValue":"default","getUndefinedValue":"default"}],"children":[],"validationRules":[],"nodeId":1,"indexes":[],"allidsShardFactor":64,"collectionName":"customers","isSingle":false}],"pathMaps":[],"indexes":[{"name":"all_customers","type":"index","map":"return {...record};","filter":"","indexType":"ancestor","getShardName":"","getSortKey":"record.id","aggregateGroups":[],"allowedRecordNodeIds":[1],"nodeId":2}],"nodeId":0},"componentLibraries":[{"importPath":"/lib/node_modules/@budibase/standard-components/dist/index.js","libName":"@budibase/standard-components"}],"appRootPath":"/testApp2","props":{}} |
window['##BUDIBASE_APPDEFINITION##'] = {"hierarchy":{"name":"root","type":"root","children":[{"name":"customer","type":"record","fields":[{"name":"name","type":"string","typeOptions":{"maxLength":null,"values":null,"allowDeclaredValuesOnly":false},"label":"Name","getInitialValue":"default","getUndefinedValue":"default"},{"name":"enquiry","type":"string","typeOptions":{"maxLength":null,"values":["Google","Facebook","Word of Mouth"],"allowDeclaredValuesOnly":true},"label":"Enquiry Source","getInitialValue":"default","getUndefinedValue":"default"}],"children":[],"validationRules":[],"nodeId":1,"indexes":[],"allidsShardFactor":64,"collectionName":"customers","isSingle":false},{"name":"Contact","type":"record","fields":[{"name":"name","type":"string","typeOptions":{"maxLength":null,"values":null,"allowDeclaredValuesOnly":false},"label":"Name","getInitialValue":"default","getUndefinedValue":"default"},{"name":"contacted","type":"bool","typeOptions":{"allowNulls":false},"label":"Has Been Contacted","getInitialValue":"default","getUndefinedValue":"default"}],"children":[],"validationRules":[],"nodeId":3,"indexes":[],"allidsShardFactor":64,"collectionName":"contacts","isSingle":false}],"pathMaps":[],"indexes":[{"name":"all_customers","type":"index","map":"return {...record};","filter":"","indexType":"ancestor","getShardName":"","getSortKey":"record.id","aggregateGroups":[],"allowedRecordNodeIds":[1],"nodeId":2},{"name":"all_contacts","type":"index","map":"return {...record};","filter":"","indexType":"ancestor","getShardName":"","getSortKey":"record.id","aggregateGroups":[],"allowedRecordNodeIds":[3],"nodeId":4}],"nodeId":0},"componentLibraries":[{"importPath":"/lib/node_modules/@budibase/standard-components/dist/index.js","libName":"@budibase/standard-components"},{"importPath":"/lib/node_modules/@budibase/bootstrap-components/dist/index.js","libName":"@budibase/bootstrap-components"}],"appRootPath":"/testApp2","props":{"_component":"@budibase/standard-components/login","logo":"","loginRedirect":"","usernameLabel":"Username","passwordLabel":"Password","loginButtonLabel":"Login","buttonClass":"","inputClass":""}} |
||||
@ -0,0 +1,9 @@ |
|||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. |
||||
|
# yarn lockfile v1 |
||||
|
|
||||
|
|
||||
|
"@budibase/bootstrap-components@file:../../../bootstrap-components": |
||||
|
version "0.0.11" |
||||
|
|
||||
|
"@budibase/standard-components@file:../../../standard-components": |
||||
|
version "0.0.11" |
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
@ -0,0 +1,49 @@ |
|||||
|
<script> |
||||
|
|
||||
|
export let condition; |
||||
|
export let thenComponent; |
||||
|
export let elseComponent; |
||||
|
|
||||
|
export let _bb; |
||||
|
|
||||
|
let element; |
||||
|
let currentEvalResult=null; |
||||
|
let currentComponent; |
||||
|
let state; |
||||
|
|
||||
|
_bb.store.subscribe(s => { |
||||
|
state = s; |
||||
|
}) |
||||
|
|
||||
|
$: { |
||||
|
if(_bb && element && state) { |
||||
|
let result; |
||||
|
try { |
||||
|
let $store = state; |
||||
|
let $context = _bb.context; |
||||
|
result = !!(Function(`"use strict";return (function($store, $context) { return (${condition}); });`)()($store, $context)); |
||||
|
} catch(e) { |
||||
|
console.log("If condition eval error: " + e.message) |
||||
|
} |
||||
|
if(result !== currentEvalResult) { |
||||
|
currentEvalResult = result; |
||||
|
if(currentComponent) { |
||||
|
currentComponent.$destroy(); |
||||
|
} |
||||
|
|
||||
|
if(result) { |
||||
|
currentComponent = _bb.hydrateComponent( |
||||
|
thenComponent,element); |
||||
|
} else if(elseComponent && elseComponent._component) { |
||||
|
currentComponent = _bb.hydrateComponent( |
||||
|
elseComponent,element); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
</script> |
||||
|
|
||||
|
<div bind:this={element}></div> |
||||
@ -1,9 +1,20 @@ |
|||||
export {default as button} from "./Button.svelte"; |
export {default as button} from "./Button.svelte"; |
||||
export {default as login} from "./Login.svelte"; |
export {default as div} from "./Div.svelte"; |
||||
export {default as form} from "./Form.svelte"; |
export {default as form} from "./Form.svelte"; |
||||
export {default as grid} from "./Grid.svelte"; |
export {default as grid} from "./Grid.svelte"; |
||||
export {default as textbox} from "./Textbox.svelte"; |
export {default as h1} from "./H1.svelte"; |
||||
export {default as stackpanel} from "./StackPanel.svelte"; |
export {default as h2} from "./H2.svelte"; |
||||
|
export {default as h3} from "./H3.svelte"; |
||||
|
export {default as h4} from "./H4.svelte"; |
||||
|
export {default as h5} from "./H5.svelte"; |
||||
|
export {default as h6} from "./H6.svelte"; |
||||
|
export {default as if} from "./If.svelte"; |
||||
|
export {default as input} from "./Input.svelte"; |
||||
|
export {default as login} from "./Login.svelte"; |
||||
export {default as nav} from "./Nav.svelte"; |
export {default as nav} from "./Nav.svelte"; |
||||
export {default as panel} from "./Panel.svelte"; |
export {default as panel} from "./Panel.svelte"; |
||||
|
export {default as select} from "./Select.svelte"; |
||||
|
export {default as stackpanel} from "./StackPanel.svelte"; |
||||
|
export {default as table} from "./Table.svelte"; |
||||
export {default as text} from "./Text.svelte"; |
export {default as text} from "./Text.svelte"; |
||||
|
export {default as textbox} from "./Textbox.svelte"; |
||||
|
|||||
Loading…
Reference in new issue