Add reset button, reset and close on parent reset
This commit is contained in:
+20
-9
@@ -21,8 +21,13 @@
|
|||||||
<input ref="field" type="hidden">
|
<input ref="field" type="hidden">
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="closebtn">
|
<li class="daterange__buttons">
|
||||||
<a class="btn btn-default btn-xs" href="#" @click.prevent="togglePanel">schließen</a>
|
<button class="daterange__button" @click.prevent="togglePanel">
|
||||||
|
<i class="fa fa-times"></i> schließen
|
||||||
|
</button>
|
||||||
|
<button class="daterange__button" @click.prevent="reset()">
|
||||||
|
<i class="fa fa-trash-o"></i> zurücksetzen
|
||||||
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
@@ -37,6 +42,7 @@
|
|||||||
import 'dayjs/locale/de'
|
import 'dayjs/locale/de'
|
||||||
import flatpickr from 'flatpickr'
|
import flatpickr from 'flatpickr'
|
||||||
import { German } from 'flatpickr/dist/l10n/de'
|
import { German } from 'flatpickr/dist/l10n/de'
|
||||||
|
import EventBus from '../_bus'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
@@ -95,19 +101,16 @@
|
|||||||
if (this.from && this.to) {
|
if (this.from && this.to) {
|
||||||
this.picker.setDate([ new Date(this.from), new Date(this.to) ]);
|
this.picker.setDate([ new Date(this.from), new Date(this.to) ]);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
EventBus.$on('filterSettingsReset', () => {
|
||||||
|
this.reset();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
selectedRange () {
|
selectedRange () {
|
||||||
if (this.selectedFrom == null && this.selectedTo == null) {
|
if (this.selectedFrom == null && this.selectedTo == null) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
if (this.selectedFrom !== null && this.selectedTo === null) {
|
|
||||||
return 'ab ' + dayjs(this.selectedFrom).format('DD.MM.YYYY');
|
|
||||||
}
|
|
||||||
if (this.selectedFrom === null && this.selectedTo !== null) {
|
|
||||||
return 'bis ' + dayjs(this.selectedTo).format('DD.MM.YYYY');
|
|
||||||
}
|
|
||||||
return dayjs(this.selectedFrom).format('DD.MM.YYYY')
|
return dayjs(this.selectedFrom).format('DD.MM.YYYY')
|
||||||
+ '-' + dayjs(this.selectedTo).format('DD.MM.YYYY');
|
+ '-' + dayjs(this.selectedTo).format('DD.MM.YYYY');
|
||||||
}
|
}
|
||||||
@@ -122,6 +125,14 @@
|
|||||||
this.picker.setDate([ this.selectedFrom, this.selectedTo ]);
|
this.picker.setDate([ this.selectedFrom, this.selectedTo ]);
|
||||||
this.togglePanel();
|
this.togglePanel();
|
||||||
this.$emit('selected', { from: this.selectedFrom, to: this.selectedTo });
|
this.$emit('selected', { from: this.selectedFrom, to: this.selectedTo });
|
||||||
|
},
|
||||||
|
reset () {
|
||||||
|
this.selectedFrom = null;
|
||||||
|
this.selectedTo = null;
|
||||||
|
this.picker.clear();
|
||||||
|
this.picker.jumpToDate();
|
||||||
|
this.togglePanel();
|
||||||
|
this.$emit('selected', { from: this.selectedFrom, to: this.selectedTo });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,6 +142,7 @@
|
|||||||
},
|
},
|
||||||
resetFilterSettings () {
|
resetFilterSettings () {
|
||||||
this.filterSettings = this.defaultFilterSettings;
|
this.filterSettings = this.defaultFilterSettings;
|
||||||
|
EventBus.$emit('filterSettingsReset');
|
||||||
this.loadResults();
|
this.loadResults();
|
||||||
},
|
},
|
||||||
updateDestination (destination) {
|
updateDestination (destination) {
|
||||||
|
|||||||
@@ -22,11 +22,17 @@
|
|||||||
color: $color-font-base;
|
color: $color-font-base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.daterange__buttons {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
.daterange__button {
|
.daterange__button {
|
||||||
color: $color-font-base;
|
color: $color-font-base;
|
||||||
border: none;
|
border: none;
|
||||||
background: none;
|
background: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
|
width: percentage(1/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.flatpickr-input {
|
.flatpickr-input {
|
||||||
|
|||||||
Reference in New Issue
Block a user