File tree Expand file tree Collapse file tree
src/main/resources/static/js/pages/editor Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 createSource ,
66 createWidget ,
77 loadSources ,
8- saveSources ,
98} from "./utils/editorActions.js" ;
109import { debounce } from "../../shared/modules/utils.js" ;
1110import {
@@ -30,7 +29,7 @@ export default class Editor {
3029 this . initGrid ( ) ;
3130
3231 // Load existing data
33- loadSources ( config . sources || [ ] ) ;
32+ loadSources ( config . sources || [ ] , config . generators || [ ] ) ;
3433 state . grid . load ( config . widgets || [ ] ) ;
3534
3635 // Replace whitespaces in the id with dashes
@@ -133,7 +132,8 @@ export default class Editor {
133132 const pipelines = await getPipelines ( ) ;
134133 const config = {
135134 id : id ,
136- sources : saveSources ( ) ,
135+ sources : state . sources ,
136+ generators : state . generators ,
137137 widgets : state . grid . save ( false ) ,
138138 } ;
139139
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ export default class SourceController {
1414 this . item = item ;
1515 }
1616
17- init ( ) {
17+ init ( generators ) {
1818 const buttons = this . root . querySelectorAll ( "button" ) ;
1919 const options = this . root . querySelector ( ".dv-dropdown-menu" ) ;
2020 const body = this . root . querySelector ( ".dv-source-card-body" ) ;
@@ -26,10 +26,13 @@ export default class SourceController {
2626 ) ;
2727
2828 // Load existing generators
29- for ( const config of this . item . createsGenerators ) {
29+ for ( const config of [
30+ ...( this . item . createsGenerators || [ ] ) ,
31+ ...generators ,
32+ ] ) {
3033 this . appendGenerator ( body , config ) ;
3134 }
32- this . item . createsGenerators = [ ] ;
35+ delete this . item . createsGenerators ;
3336
3437 // Append available generator options
3538 Object . values ( configs ) . forEach ( ( Generator ) => {
Original file line number Diff line number Diff line change @@ -4,30 +4,17 @@ import WidgetController from "../controller/WidgetController.js";
44import SourceController from "../controller/SourceController.js" ;
55import GeneratorController from "../controller/GeneratorController.js" ;
66
7- export function loadSources ( configs ) {
7+ export function loadSources ( sources , generators ) {
88 const container = document . querySelector ( ".dv-sources-container" ) ;
99
10- for ( const config of configs ) {
10+ for ( const config of sources ) {
1111 const controller = createSource ( config ) ;
1212
1313 container . prepend ( controller . root ) ;
14- controller . init ( ) ;
14+ controller . init ( generators ) ;
1515 }
1616}
1717
18- export function saveSources ( ) {
19- const sources = structuredClone ( state . sources ) ;
20-
21- for ( const generator of state . generators ) {
22- const { source : id , ...rest } = generator ;
23- const source = sources . find ( ( item ) => item . id === id ) ;
24-
25- source . createsGenerators . push ( rest ) ;
26- }
27-
28- return sources ;
29- }
30-
3118export function createSource ( config ) {
3219 const source = deepClone ( config ) ;
3320 source . id = source . id || randomId ( "Source" ) ;
You can’t perform that action at this time.
0 commit comments