-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
17,080 additions
and
4,430 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** @type { import('@storybook/vue-vite').StorybookConfig } */ | ||
const config = { | ||
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"], | ||
addons: [ | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
"@storybook/addon-docs", | ||
"@storybook/addon-interactions" | ||
], | ||
framework: { | ||
name: "@storybook/vue-vite", | ||
options: {} | ||
}, | ||
docs: { | ||
autodocs: "tag" | ||
} | ||
}; | ||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { addons } from '@storybook/manager-api'; | ||
|
||
addons.setConfig({ | ||
// Place the controls panel at the bottom of the canvas | ||
panelPosition: 'bottom', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** @type { import('@storybook/vue').Preview } */ | ||
const preview = { | ||
parameters: { | ||
actions: { argTypesRegex: "^on[A-Z].*" }, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i | ||
} | ||
} | ||
} | ||
}; | ||
|
||
export default preview; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,285 @@ | ||
import Vue from "vue"; | ||
import "bootstrap/dist/css/bootstrap.css"; | ||
import "bootstrap-vue/dist/bootstrap-vue.css"; | ||
import "@fortawesome/fontawesome-free/css/all.min.css"; | ||
import i18next from "i18next"; | ||
import VueI18Next from "@panter/vue-i18next"; | ||
import "@processmaker/vue-form-elements/dist/vue-form-elements.css"; | ||
import Vuex from "vuex"; | ||
import axios from "axios"; | ||
import { cacheAdapterEnhancer } from "axios-extensions"; | ||
import { BootstrapVue, IconsPlugin } from "bootstrap-vue"; | ||
import { Multiselect } from "@processmaker/vue-multiselect"; | ||
import "@processmaker/vue-multiselect/dist/vue-multiselect.min.css"; | ||
import { LRUCache } from "lru-cache"; | ||
import VueFormElements from "@processmaker/vue-form-elements"; | ||
import undoRedoModule from "@/store/modules/undoRedoModule"; | ||
import globalErrorsModule from "@/store/modules/globalErrorsModule"; | ||
import ScreenBuilder from "@/components"; | ||
|
||
Vue.use(BootstrapVue); | ||
Vue.use(IconsPlugin); | ||
Vue.config.productionTip = false; | ||
|
||
// Allow strings to be wrapped in $t(...) for translating | ||
// outside this package. This standalone app just returns | ||
// the English string | ||
Vue.use(VueI18Next); | ||
i18next.init({ lng: "en" }); | ||
Vue.mixin({ i18n: new VueI18Next(i18next) }); | ||
Vue.use(Vuex); | ||
Vue.use(ScreenBuilder); | ||
Vue.use(VueFormElements); | ||
Vue.component("Multiselect", Multiselect); | ||
|
||
// Stub for standalone. Real one is in core. | ||
Vue.component("Required", { | ||
template: '<div class="text-right"><small>* = Required</small></div>' | ||
}); | ||
|
||
export const store = new Vuex.Store({ | ||
modules: { | ||
globalErrorsModule, | ||
undoRedoModule | ||
} | ||
}); | ||
|
||
window.exampleScreens = [ | ||
{ | ||
id: 1, | ||
screen_category_id: 1, | ||
title: "Sub screen example", | ||
description: "A sub screen example", | ||
type: "FORM", | ||
config: [ | ||
{ | ||
name: "Sub screen example", | ||
items: [ | ||
{ | ||
config: { | ||
icon: "far fa-square", | ||
label: "First name", | ||
name: "firstname", | ||
placeholder: "", | ||
validation: "", | ||
helper: null, | ||
type: "text", | ||
dataFormat: "string", | ||
customCssSelector: "first-name" | ||
}, | ||
inspector: [], | ||
component: "FormInput", | ||
"editor-component": "FormInput", | ||
"editor-control": "FormInput", | ||
label: "Line Input", | ||
value: "__vue_devtool_undefined__" | ||
}, | ||
{ | ||
config: { | ||
icon: "far fa-square", | ||
label: "Last name", | ||
name: "lastname", | ||
placeholder: "", | ||
validation: "", | ||
helper: null, | ||
type: "text", | ||
dataFormat: "string", | ||
customCssSelector: "" | ||
}, | ||
inspector: [], | ||
component: "FormInput", | ||
"editor-component": "FormInput", | ||
"editor-control": "FormInput", | ||
label: "Line Input", | ||
value: "__vue_devtool_undefined__" | ||
} | ||
] | ||
} | ||
], | ||
computed: [], | ||
watchers: [], | ||
custom_css: "[selector='first-name'] label { font-style: italic; }", | ||
status: "ACTIVE" | ||
} | ||
]; | ||
// get cache config from header | ||
const cacheEnabled = document.head.querySelector( | ||
"meta[name='screen-cache-enabled']" | ||
); | ||
const cacheTimeout = document.head.querySelector( | ||
"meta[name='screen-cache-timeout']" | ||
); | ||
// Get the current protocol, hostname, and port | ||
const { protocol, hostname, port } = window.location; | ||
window.ProcessMaker = { | ||
isStub: true, | ||
user: { | ||
id: 1, | ||
lang: "en" | ||
}, | ||
app: { | ||
url: `${protocol}//${hostname}:${port}` // Create a URL with the current port | ||
}, | ||
apiClient: { | ||
create() { | ||
return this; | ||
}, | ||
defaults: { | ||
headers: { | ||
common: { | ||
"X-CSRF-TOKEN": "token" | ||
} | ||
} | ||
}, | ||
get(url, params) { | ||
return new Promise((resolve, reject) => { | ||
let screen; | ||
if (url.substr(0, 8) === "screens/") { | ||
screen = window.exampleScreens.find((s) => s.id == url.substr(8)); | ||
} | ||
if (url.substr(0, 8) === "screens/" && screen) { | ||
resolve({ data: screen }); | ||
} else if (url === "screens") { | ||
resolve({ | ||
data: { | ||
data: window.exampleScreens | ||
} | ||
}); | ||
} else if (url === "/data_sources/1") { | ||
resolve({ | ||
data: { | ||
endpoints: { | ||
list: {} | ||
} | ||
} | ||
}); | ||
} else if (url === "/data_sources") { | ||
resolve({ | ||
data: { | ||
data: [ | ||
{ | ||
id: 1, | ||
name: "Persons", | ||
endpoints: { | ||
list: {} | ||
} | ||
} | ||
] | ||
} | ||
}); | ||
} else { | ||
window.axios | ||
.get(url, params) | ||
.then((response) => resolve(response)) | ||
.catch((error) => reject(error)); | ||
} | ||
}); | ||
}, | ||
post(url, body) { | ||
return new Promise((resolve, reject) => { | ||
switch (url) { | ||
case "/requests/data_sources/1": | ||
resolve({ | ||
data: { | ||
response: [ | ||
{ value: 1, content: "James" }, | ||
{ value: 2, content: "John" }, | ||
{ value: 3, content: "Mary" }, | ||
{ value: 4, content: "Patricia" } | ||
] | ||
} | ||
}); | ||
break; | ||
default: | ||
window.axios | ||
.post(url, body) | ||
.then((response) => resolve(response)) | ||
.catch((error) => reject(error)); | ||
} | ||
}); | ||
}, | ||
put() { | ||
return new Promise((resolve) => { | ||
resolve({ | ||
data: { | ||
response: [] | ||
} | ||
}); | ||
}); | ||
}, | ||
delete() { | ||
return new Promise((resolve) => { | ||
resolve({ | ||
data: { | ||
response: [] | ||
} | ||
}); | ||
}); | ||
} | ||
}, | ||
EventBus: new Vue(), | ||
confirmModal(title, message, variant, callback) { | ||
if (window.confirm(`${title}: ${message}`)) { | ||
callback(); | ||
} | ||
}, | ||
alert(message, variant) { | ||
variant; | ||
message; | ||
}, | ||
screen: { | ||
cacheEnabled: cacheEnabled ? cacheEnabled.content === "true" : false, | ||
cacheTimeout: cacheTimeout ? Number(cacheTimeout.content) : 0 | ||
} | ||
}; | ||
window.Echo = { | ||
listeners: [], | ||
watcherMocks(body, response) { | ||
this.listeners.forEach((listener) => { | ||
setTimeout(() => { | ||
listener.callback({ | ||
type: ".ProcessMaker\\Events\\ScriptResponseEvent", | ||
watcher: body.watcher, | ||
response | ||
}); | ||
}, 1000); | ||
}); | ||
}, | ||
eventMocks(event, response) { | ||
this.listeners.forEach((listener) => { | ||
setTimeout(() => { | ||
listener.callback({ | ||
type: event, | ||
response | ||
}); | ||
}, 1000); | ||
}); | ||
}, | ||
private() { | ||
return { | ||
notification(callback) { | ||
window.Echo.listeners.push({ callback }); | ||
}, | ||
stopListening() { | ||
window.Echo.listeners.splice(0); | ||
}, | ||
listen(event, callback) { | ||
window.Echo.listeners.push({ event, callback }); | ||
} | ||
}; | ||
} | ||
}; | ||
|
||
window.axios = axios.create({ | ||
baseURL: "/api/1.0/", | ||
adapter: cacheAdapterEnhancer(axios.getAdapter(axios.defaults.adapter), { | ||
enabledByDefault: window.ProcessMaker.screen.cacheEnabled, | ||
cacheFlag: "useCache", | ||
defaultCache: new LRUCache({ | ||
ttl: window.ProcessMaker.screen.cacheTimeout, | ||
max: 100 | ||
}) | ||
}) | ||
}); | ||
|
||
export default { ScreenBuilder }; |
Oops, something went wrong.