Implemented Inplace component

pull/41/head
cagataycivici 2019-07-20 11:33:01 +03:00
parent a090be396d
commit 1be6c04913
3 changed files with 30 additions and 13 deletions

View File

@ -1,10 +1,18 @@
<template> <template>
<div :class="containerClass"> <div :class="containerClass">
Yoo man <div class="p-inplace-display" :tabindex="$attrs.tabindex||'0'" v-if="!d_active" @click="open" @keydown.enter="open">
<slot name="display"></slot>
</div>
<div class="p-inplace-content" v-else>
<slot name="content"></slot>
<IPButton v-if="closable" icon="pi pi-times" @click="close"></IPButton>
</div>
</div> </div>
</template> </template>
<script> <script>
import Button from '../button/Button';
export default { export default {
props: { props: {
closable: { closable: {
@ -14,10 +22,6 @@ export default {
active: { active: {
type: Boolean, type: Boolean,
defaault: false defaault: false
},
tabindex: {
type: String,
defaault: '0'
} }
}, },
watch: { watch: {
@ -30,10 +34,25 @@ export default {
d_active: this.active d_active: this.active
} }
}, },
methods: {
open(event) {
this.$emit('open', event);
this.d_active = true;
this.$emit('update:active', true);
},
close(event) {
this.$emit('close', event);
this.d_active = false;
this.$emit('update:active', false);
}
},
computed: { computed: {
containerClass() { containerClass() {
return ['p-inplace p-component', {'p-inplace-closable': this.closable}]; return ['p-inplace p-component', {'p-inplace-closable': this.closable}];
} }
},
components: {
'IPButton': Button
} }
} }
</script> </script>

View File

@ -290,9 +290,6 @@ export default {
} }
} }
} }
},
computed: {
}, },
components: { components: {
'OLButton': Button 'OLButton': Button

View File

@ -11,10 +11,10 @@
<h3>Input</h3> <h3>Input</h3>
<Inplace :closable="true"> <Inplace :closable="true">
<template #display> <template #display>
Click to Edit {{text || 'Click to Edit'}}
</template> </template>
<template #content> <template #content>
<InputText autoFocus /> <InputText v-model="text" autoFocus />
</template> </template>
</Inplace> </Inplace>
@ -25,12 +25,12 @@
<span style="margin-left:.5em; vertical-align: middle">View Picture</span> <span style="margin-left:.5em; vertical-align: middle">View Picture</span>
</template> </template>
<template #content> <template #content>
<img src="'demo/images/nature/nature1.jpg'" /> <img src="demo/images/nature/nature1.jpg" />
</template> </template>
</Inplace> </Inplace>
<h3>Lazy Data</h3> <h3>Lazy Data</h3>
<Inplace onOpen={this.onOpen}> <Inplace @open="loadData">
<template #display> <template #display>
View Data View Data
</template> </template>
@ -56,6 +56,7 @@ import InplaceDoc from './InplaceDoc';
export default { export default {
data() { data() {
return { return {
text: null,
cars: null cars: null
} }
}, },
@ -64,7 +65,7 @@ export default {
this.carService = new CarService(); this.carService = new CarService();
}, },
methods: { methods: {
onOpen() { loadData() {
this.carService.getCarsSmall().then(data => this.cars = data); this.carService.getCarsSmall().then(data => this.cars = data);
} }
}, },