Skip to content

Commit 138d5ba

Browse files
committed
[UI] Change modal default size to css & add 'autoHeight' property
1 parent f19c948 commit 138d5ba

File tree

8 files changed

+115
-53
lines changed

8 files changed

+115
-53
lines changed

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ Running 4.3.0
55
----------------------
66
[Migration help](https://github.com/vertigo-io/vertigo/wiki/Vertigo-Migration-Guide#from-420-to-430)
77

8+
* [Ui] Various fix
9+
- Fileupload, add can be triggered by keybloard
10+
- Select, searchable component state is now correctly cleared on mounting
11+
* [Ui] Change modal default size from 'style' to css & add 'autoHeight' property
12+
813
more to come :)
914

1015

vertigo-ui-vuejs/src/methods.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,30 @@ export default {
459459
var component = this.$refs[componentId];
460460
component.addFiles(event.dataTransfer.files);
461461
},
462+
modal_iframeLoad(ifrm) {
463+
let compId = ifrm.dataset.componentId;
464+
let autoHeight = ifrm.dataset.autoHeight;
465+
let doc = ifrm.contentDocument? ifrm.contentDocument: ifrm.contentWindow.document;
466+
467+
if (autoHeight === 'true') {
468+
ifrm.style.opacity = '0'; // should be already hidden but otherwise we hide it to avoid flickering
469+
//ifrm.style.height = "100px"; // set to 100px to get height without blank padding at bottom, but not less than 100px
470+
471+
let newHeight = this.getDocHeight(doc) + 4 + "px"; // IE opt. for bing/msn needs a bit added or scrollbar appears
472+
473+
ifrm.style.height = ""; // reset iframe height to extends again
474+
this.componentStates[compId].height = newHeight; // set the height of the modal
475+
}
476+
this.componentStates[compId].loading = false;
477+
ifrm.style.opacity = '1'; // show the iframe
478+
},
479+
getDocHeight : function(doc) {
480+
doc = doc || document;
481+
let body = doc.body, html = doc.documentElement;
482+
let height = Math.max( body.scrollHeight, body.offsetHeight,
483+
html.scrollHeight, html.offsetHeight, html.clientHeight);
484+
return height;
485+
},
462486
httpPostAjax: function (url, paramsIn, options) {
463487
var paramsInResolved = !paramsIn ? [] : Array.isArray(paramsIn) ? this.vueDataParams(paramsIn) : paramsIn;
464488
let vueData = this.$data.vueData;

vertigo-ui/src/main/resources/io/vertigo/ui/components/layout/modal.html

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
<th:block th:fragment="modal(componentId, title, closeLabel, srcUrl, width, height, iframe_attrs, section_attrs, modal_attrs)"
1+
<th:block th:fragment="modal(componentId, title, closeLabel, srcUrl, width, height, autoHeight, iframe_attrs, section_attrs, modal_attrs)"
22
th:assert="${componentId} != null"
3-
th:attr=" objectKey=${model.vContext['componentStates'].addComponentState(componentId).addPrimitive('opened', false)},
4-
objectKey=${model.vContext['componentStates']['__${componentId}__'].addPrimitive('title', title?:'')},
5-
objectKey=${model.vContext['componentStates']['__${componentId}__'].addPrimitive('srcUrl', srcUrl?:'')}" >
3+
th:attr=" objectKey=${model.vContext['componentStates'].addComponentState(componentId)
4+
.addPrimitive('opened', false)
5+
.addPrimitive('loading', true)
6+
.addPrimitive('title', title?:'')
7+
.addPrimitive('srcUrl', srcUrl?:'')
8+
.addPrimitive('width', width?:'')
9+
.addPrimitive('height', height?:'')}" >
610
<q-dialog th:v-model="|componentStates.${componentId}.opened|" th:attr="__${modal_attrs}__">
711
<vu:content>
812
<q-card class="bg-white v-modal">
913
<q-toolbar class="bg-primary" th:if="${title != null}">
1014
<vu:button flat dense v-close-popup icon="keyboard_arrow_left" color="primary" textColor="white" th:title="#{layout.modal.close}" />
1115
<q-toolbar-title class="text-white">{{ componentStates.[[${componentId}]].title }}</q-toolbar-title>
1216
</q-toolbar>
13-
<q-card-section class="q-pa-none" th:style="|width:${width?:'560px'};height:${height?:'420px'}" th:attr="__${section_attrs}__">
14-
<iframe th:v-bind:src="|componentStates.${componentId}.srcUrl|" th:attr="__${iframe_attrs}__" ></iframe>
17+
<q-card-section class="q-pa-none" th::style="|{width:componentStates.${componentId}.width, height:componentStates.${componentId}.height}|" th:attr="__${section_attrs}__">
18+
<div class="loading absolute-center" th:v-if="|componentStates.${componentId}.loading|"><q-spinner-tail size="xl"></q-spinner-tail></div>
19+
<iframe th:v-bind:src="|componentStates.${componentId}.srcUrl|"
20+
th:attr="__${iframe_attrs}__"
21+
th:style="${autoHeight == true ? 'height:100px; opacity:0':''}"
22+
th:@vue:before-mount="|componentStates.${componentId}.loading=true; componentStates.${componentId}.height='${height?:''}';|"
23+
onload="VUiPage.modal_iframeLoad(this)"
24+
th:data-auto-height="${autoHeight}"
25+
th:data-component-id="${componentId}"></iframe>
1526
</q-card-section>
1627
<q-toolbar th:if="${closeLabel} != null" class="bg-primary" >
1728
<q-btn flat v-close-popup th:label="${closeLabel}" text-color="white" ></q-btn>

vertigo-ui/src/main/resources/io/vertigo/ui/static/css/vertigo-ui.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,8 @@ table .q-uploader .q-btn {
432432
}
433433

434434
.q-dialog__inner--minimized .v-modal .q-card__section {
435+
width: 560px;
436+
height: 420px;
435437
max-height: calc(100vh - 100px);
436438
max-width: calc(100vw - 100px);
437439
overflow: auto;

0 commit comments

Comments
 (0)