mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-08 06:03:04 -04:00
[nextgen/cardstack] big improvements
- Implement return types - page numbers - better subpage resolve delay - error handling and system error cards - code cleanup
This commit is contained in:
parent
7e850e5b5d
commit
18bd28591c
6 changed files with 249 additions and 125 deletions
|
@ -2,6 +2,7 @@ const { createEmbed, page } = require("#utils/embed");
|
|||
const { acknowledge } = require("#utils/interactions");
|
||||
|
||||
const { DynamicCardStack } = require("../../../labscore/cardstack/DynamicCardStack");
|
||||
const {CARD_STACK_CONSTANTS} = require("#cardstack");
|
||||
|
||||
module.exports = {
|
||||
label: "text",
|
||||
|
@ -25,6 +26,9 @@ module.exports = {
|
|||
createEmbed("default", context, { description: "page 1"}),
|
||||
createEmbed("default", context, { description: "page 2. this has a conditional button."})
|
||||
].map((p, index)=>page(p, {}, { key: `t_${index}` })),
|
||||
pageNumberGenerator: (pg)=>{
|
||||
return `Test ${pg.index}`
|
||||
},
|
||||
interactive: {
|
||||
always_active_button: {
|
||||
label: "single sub page",
|
||||
|
@ -32,9 +36,12 @@ module.exports = {
|
|||
visible: true,
|
||||
disableCache: true,
|
||||
resolvePage: ()=>{
|
||||
return [
|
||||
createEmbed("success", context, "smiley")
|
||||
].map((p)=>page(p))
|
||||
return {
|
||||
type: CARD_STACK_CONSTANTS.RESOLVE_CALLBACK_TYPES.SUBSTACK,
|
||||
cards: [
|
||||
createEmbed("success", context, "smiley")
|
||||
].map((p)=>page(p))
|
||||
}
|
||||
}
|
||||
},
|
||||
conditional_button: {
|
||||
|
@ -46,16 +53,20 @@ module.exports = {
|
|||
return (page.getState("key") === "t_1")
|
||||
},
|
||||
resolvePage: (pg) => {
|
||||
return [
|
||||
createEmbed("default", context, { description: "this is a conditional sub page"}),
|
||||
createEmbed("default", context, { description: "this is a conditional sub page two"})
|
||||
].map((p)=>page(p));
|
||||
return {
|
||||
type: CARD_STACK_CONSTANTS.RESOLVE_CALLBACK_TYPES.SUBSTACK,
|
||||
cards: [
|
||||
createEmbed("default", context, { description: "this is a conditional sub page"}),
|
||||
createEmbed("default", context, { description: "this is a conditional sub page two"})
|
||||
].map((p)=>page(p))
|
||||
}
|
||||
}
|
||||
},
|
||||
dynamic_button: {
|
||||
// Button Label
|
||||
label: (page) => {
|
||||
return page.getState("key");
|
||||
console.log(page.getState("key"))
|
||||
return page.getState("key") || "test";
|
||||
},
|
||||
// Next to pagination or new row
|
||||
inline: false,
|
||||
|
@ -63,67 +74,19 @@ module.exports = {
|
|||
// Renders the loading state card
|
||||
renderLoadingState: (page) => {
|
||||
return createEmbed("default", context, {
|
||||
description: "-# Subpage Loading :)",
|
||||
description: "-# replacing papa card",
|
||||
})
|
||||
},
|
||||
resolvePage: async (pg) => {
|
||||
console.log("resolving page")
|
||||
return [
|
||||
createEmbed("default", context, { description: "this is a dynamic sub page " + Math.random()}),
|
||||
createEmbed("default", context, { description: "this is a dynamic sub page " + Math.random()}),
|
||||
createEmbed("default", context, { description: "this is a dynamic sub page " + Math.random()}),
|
||||
createEmbed("default", context, { description: "this is a dynamic sub page " + Math.random()})
|
||||
].map((p)=>page(p));
|
||||
return {
|
||||
type: CARD_STACK_CONSTANTS.RESOLVE_CALLBACK_TYPES.REPLACE_PARENT_CARD,
|
||||
card: page(createEmbed("default", context, { description: "this is the new over lord " + new Date()}), {}, {
|
||||
key: Date.now()
|
||||
})
|
||||
};
|
||||
}
|
||||
},
|
||||
conditional_button_2: {
|
||||
// Button Label
|
||||
label: "Conditional",
|
||||
// Next to pagination or new row
|
||||
inline: false,
|
||||
visible: true,
|
||||
resolvePage: (pg) => {throw "a"}
|
||||
},
|
||||
conditional_button_3: {
|
||||
// Button Label
|
||||
label: "Conditional",
|
||||
// Next to pagination or new row
|
||||
inline: false,
|
||||
visible: true,
|
||||
resolvePage: (pg) => {throw "a"}
|
||||
},
|
||||
conditional_button_4: {
|
||||
// Button Label
|
||||
label: "Conditional",
|
||||
// Next to pagination or new row
|
||||
inline: false,
|
||||
visible: true,
|
||||
resolvePage: (pg) => {throw "a"}
|
||||
},
|
||||
conditional_button_5: {
|
||||
// Button Label
|
||||
label: "Conditional",
|
||||
// Next to pagination or new row
|
||||
inline: false,
|
||||
visible: true,
|
||||
resolvePage: (pg) => {throw "a"}
|
||||
},
|
||||
conditional_button_6: {
|
||||
// Button Label
|
||||
label: "Conditional",
|
||||
// Next to pagination or new row
|
||||
inline: false,
|
||||
visible: true,
|
||||
resolvePage: (pg) => {throw "a"}
|
||||
},
|
||||
conditional_button_7: {
|
||||
// Button Label
|
||||
label: "Conditional",
|
||||
// Next to pagination or new row
|
||||
inline: false,
|
||||
visible: true,
|
||||
resolvePage: (pg) => {throw "a"}
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
}catch(e){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue