2
0
mirror of https://github.com/frappe/books.git synced 2025-01-23 15:18:24 +00:00
This commit is contained in:
Suraj Shetty 2018-07-14 20:06:17 +05:30
commit 815f4d5883
9 changed files with 105 additions and 63 deletions

View File

@ -159,7 +159,7 @@ export default {
} }
</script> </script>
<style lang="scss"> <style lang="scss">
@import "frappe-datatable/dist/frappe-datatable.css"; @import "~frappe-datatable/dist/frappe-datatable.css";
.datatable-wrapper { .datatable-wrapper {
.form-control { .form-control {

View File

@ -35,4 +35,3 @@ export default {
} }
}; };
</script> </script>

View File

@ -57,6 +57,7 @@ export default {
}, },
filter() { filter() {
// return a function that filters list suggestions based on input // return a function that filters list suggestions based on input
return Awesomplete.FILTER_CONTAINS
} }
} }
}; };

View File

@ -8,7 +8,7 @@ export default {
}, },
props: { props: {
docfield: Object, docfield: Object,
value: [String, Number, Array], value: [String, Number, Array, FileList],
onlyInput: { onlyInput: {
type: Boolean, type: Boolean,
default: false default: false
@ -93,6 +93,9 @@ export default {
const isValid = await this.validate(value); const isValid = await this.validate(value);
this.$refs.input.setCustomValidity(isValid === false ? 'error' : ''); this.$refs.input.setCustomValidity(isValid === false ? 'error' : '');
this.$emit('change', value); this.$emit('change', value);
},
getValueFromInput(e) {
}, },
validate() { validate() {
return true; return true;

View File

@ -0,0 +1,31 @@
<template>
<div :class="{'form-group': !onlyInput}">
<label v-if="!onlyInput">{{ docfield.label }}</label>
<flat-pickr
class="form-control"
:value="value"
:config="config"
@on-change="emitChange">
</flat-pickr>
</div>
</template>
<script>
import flatPickr from 'vue-flatpickr-component';
import Data from './Data';
export default {
extends: Data,
props: ['config'],
components: {
flatPickr
},
methods: {
emitChange(dates, dateString) {
this.$emit('change', dateString);
}
}
};
</script>
<style lang="scss">
@import "~flatpickr/dist/flatpickr.css";
</style>

View File

@ -1,29 +1,13 @@
<template>
<div :class="{'form-group': !onlyInput}">
<label v-if="!onlyInput">{{ docfield.label }}</label>
<flat-pickr
:value="value"
class="form-control"
@on-change="emitChange">
</flat-pickr>
</div>
</template>
<script> <script>
import flatPickr from 'vue-flatpickr-component'; import BaseDate from './BaseDate';
import Data from './Data';
export default { export default {
extends: Data, extends: BaseDate,
components: { props: {
flatPickr config: {
}, type: Object,
methods: { default: () => ({})
emitChange(dates, dateString) {
this.$emit('change', dateString);
} }
} }
}; };
</script> </script>
<style lang="scss">
@import "flatpickr/dist/flatpickr.css";
</style>

View File

@ -10,7 +10,7 @@ export default {
}, },
methods: { methods: {
getWrapperElement(h) { getWrapperElement(h) {
let fileName = 'Choose a file..'; let fileName = this._('Choose a file..');
if (this.$refs.input && this.$refs.input.files.length) { if (this.$refs.input && this.$refs.input.files.length) {
fileName = this.$refs.input.files[0].name; fileName = this.$refs.input.files[0].name;
@ -39,9 +39,18 @@ export default {
type: 'file', type: 'file',
value: this.value, value: this.value,
required: this.docfield.required, required: this.docfield.required,
disabled: this.disabled disabled: this.disabled,
} webkitdirectory: this.docfield.directory,
} directory: this.docfield.directory
};
},
getInputListeners() {
return {
change: e => {
this.handleChange(e.target.files);
}
};
} }
} }
};
</script> </script>

View File

@ -1,39 +1,16 @@
<template>
<div :class="{ 'form-group': !onlyInput }">
<label v-if="!onlyInput">{{ docfield.label }}</label>
<flat-pickr
:value="value"
:config="config"
class="form-control"
@on-change="emitChange"
>
</flat-pickr>
</div>
</template>
<script> <script>
import flatPickr from 'vue-flatpickr-component'; import BaseDate from './BaseDate';
import Data from './Data';
export default { export default {
extends: Data, extends: BaseDate,
data() { props: {
return {
config: { config: {
type: Object,
default: () => ({
enableTime: true, enableTime: true,
noCalendar: true noCalendar: true
} })
};
},
components: {
flatPickr
},
methods: {
emitChange(times, timeString) {
this.$emit('change', timeString);
} }
} }
}; };
</script> </script>
<style lang="scss">
@import "flatpickr/dist/flatpickr.css";
</style>

38
ui/plugins/frappeVue.js Normal file
View File

@ -0,0 +1,38 @@
/**
* Vue Plugin that registers common UI elements
* like Button and Modal into the root Vue instance
*/
import frappe from 'frappejs';
import NotFound from '../components/NotFound';
import FeatherIcon from '../components/FeatherIcon';
import FrappeControl from '../components/controls/FrappeControl';
import Button from '../components/Button';
import Indicator from '../components/Indicator';
import modalPlugin from '../components/Modal/plugin';
import formModalPlugin from '../plugins/formModal';
export default function installFrappePlugin(Vue) {
Vue.component('not-found', NotFound);
Vue.component('feather-icon', FeatherIcon);
Vue.component('frappe-control', FrappeControl);
Vue.component('f-button', Button);
Vue.component('indicator', Indicator);
Vue.use(modalPlugin);
Vue.use(formModalPlugin);
Vue.mixin({
computed: {
frappe() {
return frappe;
}
},
methods: {
// global translation function in every component
_(...args) {
return frappe._(...args);
}
}
});
}