Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live preview #434

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
397b883
preview
johnpuddephatt Feb 5, 2023
0bf7575
import _ for debounce
johnpuddephatt Feb 13, 2023
826177f
remove manually defined view. infer from layout name instead
johnpuddephatt Feb 14, 2023
df78bc5
merge previewStylesheet and enablePreview
johnpuddephatt Feb 14, 2023
ee5f3a1
increase initial iframe size to address vh issues
johnpuddephatt Feb 14, 2023
8565ff0
WIP
johnpuddephatt Feb 20, 2023
b4aea67
new fullScreen mode
johnpuddephatt Feb 21, 2023
7949652
WIP
johnpuddephatt Feb 21, 2023
0bd7eb9
WIP – previews now displaying on 'view' page
johnpuddephatt Feb 22, 2023
01835e2
Merge branch 'whitecube:master' into master
johnpuddephatt Feb 22, 2023
dc09a30
store/restore scrollTop when going full screen
johnpuddephatt Feb 22, 2023
39890cd
Merge branch 'master' of https://github.com/johnpuddephatt/nova-flexi…
johnpuddephatt Feb 22, 2023
1808dc4
allow image preview method to be defined on layout class
johnpuddephatt Feb 23, 2023
17bf81e
WIP
johnpuddephatt Feb 28, 2023
74552a3
min height on iframe
johnpuddephatt Mar 1, 2023
d985514
min height on iframe
johnpuddephatt Mar 1, 2023
6cf0bd7
empty preview
johnpuddephatt Mar 1, 2023
4db8463
preview iframe
johnpuddephatt Mar 1, 2023
97a2322
preview iframe
johnpuddephatt Mar 1, 2023
270639f
implement validation/error handling
johnpuddephatt Mar 9, 2023
87fa35c
error handling
johnpuddephatt Mar 9, 2023
33cd4dc
fix route names
johnpuddephatt Mar 13, 2023
9e51c57
defaultLayouts method...
johnpuddephatt Mar 14, 2023
9b04dc8
debug height of iframe
johnpuddephatt Mar 28, 2023
a5abddb
add height to iframe
johnpuddephatt Mar 28, 2023
a95cbba
hide overflow on iframe preview
johnpuddephatt Mar 28, 2023
7a9f67b
iframe height
johnpuddephatt Mar 28, 2023
ca53dfc
don't open fieldsets without previews
johnpuddephatt Mar 29, 2023
a4c4abf
Merge branch 'whitecube:master' into master
johnpuddephatt Mar 29, 2023
552841a
work with nova fields with storage callbacks
johnpuddephatt Mar 29, 2023
298147f
don't json decode
johnpuddephatt Mar 29, 2023
fab3669
don't stringify either.
johnpuddephatt Mar 29, 2023
113a044
add logic to ViewController to handle files
johnpuddephatt Mar 30, 2023
da6c892
forgot null is an object
johnpuddephatt Mar 30, 2023
5deac57
overflow hidden preventing 'add block' menu from displaying properly
johnpuddephatt May 29, 2023
7faac6a
remove overflow hidden
johnpuddephatt May 29, 2023
577da17
updated
johnpuddephatt Jul 19, 2023
bda864d
Merge pull request #1 from whitecube/master
johnpuddephatt Jul 19, 2023
00d38a7
update preview controller
johnpuddephatt Aug 18, 2023
f747df3
Merge branch 'master' into dev
johnpuddephatt Aug 31, 2024
8778db7
Merge pull request #5 from johnpuddephatt/dev
johnpuddephatt Aug 31, 2024
b633967
build
johnpuddephatt Aug 31, 2024
9b2a4fd
ignore
johnpuddephatt Aug 31, 2024
568e48f
popover
johnpuddephatt Oct 17, 2024
354f6f5
allow opening a group with #NAME_ID
johnpuddephatt Nov 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ phpunit.xml
Thumbs.db
yarn-error.log
webpack.mix.js
auth.json
8 changes: 8 additions & 0 deletions auth.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"http-basic": {
"nova.laravel.com": {
"username": "[email protected]",
"password": "UFatuHRAicf5Wi8EGJHxBA1FoweIFvZNs2S0QFeLgb7M4RR2Dl"
}
}
}
2 changes: 1 addition & 1 deletion dist/css/field.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/field.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**!
* Sortable 1.15.0
* Sortable 1.15.2
* @author RubaXa <[email protected]>
* @author owenm <[email protected]>
* @license MIT
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@
"sortablejs": "^1.15.0",
"vue-loader": "^16.8.3",
"vuex": "^4.0.2"
},
"dependencies": {
"laravel-nova-ui": "^0.4.12",
"underscore": "^1.13.6"
}
}
3 changes: 3 additions & 0 deletions resources/js/components/DetailField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
:resourceName="resourceName"
:resourceId="resourceId"
:attribute="field.attribute"
:previewStylesheet="field.enablePreview"
/>
</div>
</template>
Expand Down Expand Up @@ -87,13 +88,15 @@ export default {
fields,
this.field,
key,
layout.preview,
collapsed,
layout,
resolved_title
);

this.groups[group.key] = group;
this.order.push(group.key);

},
},
};
Expand Down
58 changes: 55 additions & 3 deletions resources/js/components/DetailGroup.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div :class="componentStyle" :dusk="'detail-'+attribute+'-'+index">
<div v-if="!previewStylesheet" :class="componentStyle" :dusk="'detail-'+attribute+'-'+index">
<div :class="titleStyle" v-if="group.title">
<span class="block float-left border-r border-gray-100 dark:border-gray-700 pr-4 mr-4"><!--
--><span class="text-60 text-xs">#</span><!--
Expand All @@ -17,12 +17,17 @@
:validation-errors="null"
:class="{ 'remove-bottom-border': index == group.fields.length - 1 }"
/>
</div>
</div>
<preview-iframe v-else-if="initialPreviewHtml" :stylesheet="previewStylesheet" :flexible_key="group.key" :initialPreviewHtml="initialPreviewHtml" :updatedPreviewHtml="updatedPreviewHtml" />
</template>

<script>
import PreviewIframe from './PreviewIframe';

export default {
props: ['attribute', 'group', 'index', 'last', 'resource', 'resourceName', 'resourceId'],
components: {PreviewIframe},

props: ['attribute', 'group', 'index', 'last', 'resource', 'resourceName', 'resourceId', 'previewStylesheet'],

computed: {
componentStyle() {
Expand All @@ -31,6 +36,53 @@ export default {
titleStyle() {
return ['pb-4', 'border-b', 'border-gray-100', 'dark:border-gray-700'];
}
},

data() {
return {
form: new FormData(),
initialPreviewHtml: null,
updatedPreviewHtml: null,
}
},

mounted() {
this.$nextTick(() => {
this.group.fields.forEach((field) => {
this.form.set("__key", this.group.key);
this.form.set(field.attribute, ((typeof field.value === 'object' && field.value !== null) ?
JSON.stringify(field.value) : (field.value ?? '')));
});
this.getPreview();
});

},

methods: {
getPreview() {
fetch(
`/nova-vendor/flexible/view/${this.resourceName}/${this.resourceId}/${this.attribute}/${this.group.name}`,
{
method: "post",
body: this.form,
headers: {
"X-CSRF-TOKEN": document.querySelector(
'meta[name="csrf-token"]'
).content,
},
}
)
.then((response) => response.json())
.then((json) => {

if(!this.initialPreviewHtml || json.has_uploads) {
this.initialPreviewHtml = json.view;
}
else {
this.updatedPreviewHtml = json.view;
}
});
},
}
}
</script>
Loading