From d4442d2be1a41c60fe86bb1e2be0e6ce69e665dd Mon Sep 17 00:00:00 2001 From: katashin Date: Mon, 21 May 2018 16:04:45 +0900 Subject: [PATCH] feat: allow to modify props and data in preview pane (#32) * chore: add a json input component * chore: retain modified scope of document * chore: show document scope for rendering component * chore: provide default value as scope to component catalog * feat: enable to update props / data value in preview --- .../components/ComponentCatalogPreview.vue | 27 ++- src/view/components/ContainerVueComponent.vue | 17 +- src/view/components/InputJson.vue | 54 +++++ src/view/components/PageMain.vue | 10 +- src/view/components/Renderer.vue | 9 +- src/view/components/ScopeInformation.vue | 70 ++++-- src/view/components/VueComponent.vue | 33 +-- src/view/store/modules/project.ts | 110 +++++++++ test/helpers/template.ts | 17 +- test/view/Renderer.spec.ts | 10 + test/view/store/project.spec.ts | 215 ++++++++++++++++++ 11 files changed, 523 insertions(+), 49 deletions(-) create mode 100644 src/view/components/InputJson.vue diff --git a/src/view/components/ComponentCatalogPreview.vue b/src/view/components/ComponentCatalogPreview.vue index 55c575d..29cabf0 100644 --- a/src/view/components/ComponentCatalogPreview.vue +++ b/src/view/components/ComponentCatalogPreview.vue @@ -5,8 +5,7 @@ :uri="component.uri" :template="component.template" :styles="component.styleCode" - :props="component.props" - :data="component.data" + :scope="scope" :child-components="component.childComponents" /> @@ -16,7 +15,7 @@ diff --git a/src/view/components/ContainerVueComponent.vue b/src/view/components/ContainerVueComponent.vue index daa0bbe..b546422 100644 --- a/src/view/components/ContainerVueComponent.vue +++ b/src/view/components/ContainerVueComponent.vue @@ -3,8 +3,7 @@ v-if="document" :uri="uri" :template="document.template" - :props="document.props" - :data="document.data" + :scope="scope" :child-components="document.childComponents" :styles="document.styleCode" :props-data="propsData" @@ -14,7 +13,11 @@ + + diff --git a/src/view/components/PageMain.vue b/src/view/components/PageMain.vue index 35d7975..b1fdc28 100644 --- a/src/view/components/PageMain.vue +++ b/src/view/components/PageMain.vue @@ -5,6 +5,7 @@
- +

Not found

Not found

@@ -112,6 +117,7 @@ export default Vue.extend({ ...projectHelpers.mapGetters({ document: 'currentDocument', + scope: 'currentScope', renderingDocument: 'currentRenderingDocument', scopedDocuments: 'scopedDocuments' }), @@ -135,6 +141,8 @@ export default Vue.extend({ 'updateDeclaration' ]), + ...projectHelpers.mapMutations(['updatePropValue', 'updateDataValue']), + ...viewportHelpers.mapActions(['resize', 'zoom']), onStartDragging(uri: string): void { diff --git a/src/view/components/Renderer.vue b/src/view/components/Renderer.vue index aad2c3d..52f950e 100644 --- a/src/view/components/Renderer.vue +++ b/src/view/components/Renderer.vue @@ -12,8 +12,7 @@ ScopedDocument, required: true }, + scope: { + type: Object as () => DocumentScope, + required: true + }, selectedPath: { type: Array as () => number[], required: true diff --git a/src/view/components/ScopeInformation.vue b/src/view/components/ScopeInformation.vue index c3dd622..5dd5ef2 100644 --- a/src/view/components/ScopeInformation.vue +++ b/src/view/components/ScopeInformation.vue @@ -2,14 +2,14 @@

Props

-
    -
  • - {{ prop.name }} +
      +
    • + {{ name }} - - {{ prop.type }} - - {{ prop.default }} +
    @@ -20,11 +20,14 @@

    Data

    -
      -
    • - {{ d.name }} +
        +
      • + {{ name }} - {{ d.default }} +
      @@ -37,19 +40,46 @@