A component (models.Component, component.graphql) is a named HTML box. "+ New box" now lists components and places a copy, as it did with the hard-coded starters; the canvas's new Components button (ComponentPanel) can also place one linked. A linked box has Box.componentId, its row's html is nil, and the resolvers fill in the component's html before answering (fillLinked), so saving the html in the box editor saves the component and every linked box on every page changes. Only the html is shared: title, geometry, frame and visibility stay each box's own. The box editor gains "Save as component" (makes one from an html box and links it) and, on a linked box, a banner with Detach (gives the box its own copy). updateBox refuses html on a linked box. Deleting a component detaches its boxes first, so no page changes. Layouts store the link and the html; loading relinks only if the component still exists. The built-in starters in templates.js are no longer listed directly: "Import built-ins" in the panel creates them as components (skipping names already taken), so they can be edited and deleted like the rest. The html helpers there are unchanged. Everything is @admin. Co-Authored-By: Claude Opus 5.5 <[email protected]>
74 lines
1.6 KiB
GraphQL
74 lines
1.6 KiB
GraphQL
# Boxes on a canvas page: the landing page (page "index") or an
|
|
# admin-created Page (page = its slug; the home page /stp is the Page "stp").
|
|
# Anyone may read a page's layout — it is the page — but only an admin may
|
|
# change it, and adminOnly boxes are only ever returned to an admin. x/y/w/h
|
|
# are px on a fixed 1400px-wide design canvas; see models.Box.
|
|
#
|
|
# kind is "widget" (a built-in Vue component named by `widget`) or "html"
|
|
# (`html` rendered in a sandboxed iframe on the front end). An html box with a
|
|
# componentId is linked to that Component: its html is the component's, and
|
|
# updateBox refuses to change it (component.graphql).
|
|
|
|
type Box {
|
|
id: ID!
|
|
createdAt: Time!
|
|
updatedAt: Time!
|
|
page: String!
|
|
kind: String!
|
|
widget: String
|
|
html: String
|
|
title: String
|
|
x: Int!
|
|
y: Int!
|
|
w: Int!
|
|
h: Int!
|
|
z: Int!
|
|
framed: Boolean!
|
|
hideOnMobile: Boolean!
|
|
adminOnly: Boolean!
|
|
componentId: ID
|
|
}
|
|
|
|
input CreateBoxInput {
|
|
page: String!
|
|
kind: String!
|
|
widget: String
|
|
html: String
|
|
title: String
|
|
x: Int
|
|
y: Int
|
|
w: Int
|
|
h: Int
|
|
z: Int
|
|
framed: Boolean
|
|
hideOnMobile: Boolean
|
|
adminOnly: Boolean
|
|
# Links the new box to this component; kind is then "html" and html is
|
|
# ignored.
|
|
componentId: ID
|
|
}
|
|
|
|
input UpdateBoxInput {
|
|
widget: String
|
|
html: String
|
|
title: String
|
|
x: Int
|
|
y: Int
|
|
w: Int
|
|
h: Int
|
|
z: Int
|
|
framed: Boolean
|
|
hideOnMobile: Boolean
|
|
adminOnly: Boolean
|
|
}
|
|
|
|
extend type Query {
|
|
boxes(page: String!): [Box!]!
|
|
}
|
|
|
|
extend type Mutation {
|
|
createBox(input: CreateBoxInput!): Box! @admin
|
|
updateBox(id: ID!, input: UpdateBoxInput!): Box! @admin
|
|
deleteBox(id: ID!): Box! @admin
|
|
}
|