Skip to content

Commit

Permalink
Waltz Svelte Component now cascades destroy events from angular to sv…
Browse files Browse the repository at this point in the history
…elte

finos#7000
  • Loading branch information
davidwatkins73 committed Feb 23, 2024
1 parent 618c7fb commit 914e056
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 248 deletions.
11 changes: 11 additions & 0 deletions waltz-ng/client/playpen/1/Child.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script>
import {onDestroy, onMount} from "svelte";
onMount(() => console.log("child onMount"));
onDestroy(() => console.log("child onDestroy"));
</script>

<h1>
Hello child
</h1>
201 changes: 0 additions & 201 deletions waltz-ng/client/playpen/1/GridDemo.svelte

This file was deleted.

25 changes: 25 additions & 0 deletions waltz-ng/client/playpen/1/Parent.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<script>
import {onDestroy, onMount} from "svelte";
import Child from "./Child.svelte";
onMount(() => console.log("parent onMount"));
onDestroy(() => console.log("parent onDestroy"));
let show = true;
export let counter = 0;
$: d = counter * counter;
</script>

<h1>Hello Parent: counter is {counter}, sq: {d}</h1>


<button on:click={() => show = !show}>Toggle Child</button>

{#if show}
<Child/>
{/if}

12 changes: 12 additions & 0 deletions waltz-ng/client/playpen/1/Unaware.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script>
import {onDestroy, onMount} from "svelte";
export let counter = 0;
onMount(() => console.log("unaware onMount"));
onDestroy(() => console.log("unaware onDestroy"));
</script>

<h1>Hello Unaware: counter is {counter}</h1>


39 changes: 39 additions & 0 deletions waltz-ng/client/playpen/1/lifecycle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import _ from "lodash";
import {isRemoved} from "../../common/entity-utils";
import {initialiseData} from "../../common";
import {columnDef, withWidth} from "../../physical-flow/physical-flow-table-utilities";
import template from "../../physical-specifications/components/physical-data-section/physical-data-section.html";

const bindings = {

};


const initialState = {

};


function controller() {

const vm = initialiseData(this, initialState);

vm.$onInit = () => {
console.log("lifecycle onInit");
}
vm.$onDestroy = () => {
console.log("lifecycle onDestroy");
}
}

controller.$inject = ["$scope"];


const component = {
template,
bindings,
controller
};


export default component;
17 changes: 12 additions & 5 deletions waltz-ng/client/playpen/1/playpen1.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
-->

<div>

<waltz-page-header name="Playpen"
small="1"
icon="rocket">
Expand All @@ -28,11 +27,19 @@
</waltz-page-header>


<div class="row">
<div class="col-md-3">
<waltz-svelte-component component="$ctrl.DataTypeTreeSelector" selection-filter="$ctrl.filter">
<div class="row" >
<div class="col-md-12">
<button ng-click="$ctrl.visible = !$ctrl.visible">Toggle Both</button>
<button ng-click="$ctrl.counter = $ctrl.counter + 1">Inc {{$ctrl.counter}}</button>
<div ng-if="$ctrl.visible">
<waltz-svelte-component component="$ctrl.Unaware" u="$ctrl.u" counter="$ctrl.counter">

</waltz-svelte-component>
<waltz-svelte-component component="$ctrl.Parent" p="$ctrl.p" counter="$ctrl.counter">

</waltz-svelte-component>
</div>

</waltz-svelte-component>
</div>
</div>

Expand Down
28 changes: 9 additions & 19 deletions waltz-ng/client/playpen/1/playpen1.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@

import template from "./playpen1.html";
import {initialiseData} from "../../common";
import {CORE_API} from "../../common/services/core-api-utils";
import {directLineage} from "../../common/hierarchy-utils";
import Parent from "./Parent.svelte";
import Unaware from "./Unaware.svelte";

const initData = {
taxonomy: []
Parent,
Unaware,
p: "ParentParam",
u: "UnawareParam",
visible: true,
counter: 1

};


Expand All @@ -34,23 +40,7 @@ function controller($q,

vm.$onInit = () => {

serviceBroker
.loadViewData(
CORE_API.MeasurableStore.findAll,
[])
.then(r => {
vm.taxonomy = _.filter(r.data, m => m.categoryId === 6);

console.log({
taxonomy: vm.taxonomy,
sliver: directLineage(vm.taxonomy, 117)
});
});

}



}

controller.$inject = ["$q", "ServiceBroker", "UserService"];
Expand Down
Loading

0 comments on commit 914e056

Please sign in to comment.