update files

This commit is contained in:
nuintun
2015-11-24 12:23:27 +08:00
parent a3980af265
commit a058067ed0
12 changed files with 100 additions and 110 deletions

View File

@@ -16,10 +16,9 @@
<span></span>
</div>
<div class="ui-popup-content">
<div v-show="submitError" class="ui-submit-tips">{{ submitError }}</div>
<form @submit.prevent="add" @focusin="focus">
<form @submit.prevent="add">
<ul>
<li v-ref:base is="project-base" :name.sync="name" :path.sync="path"></li>
<li v-ref:base is="project-base" :name.sync="name" :path.sync="path" :unique="unique"></li>
<li class="ui-popup-control">
<input type="submit" class="ui-button" value="确定"/>
<input @click.stop="hidePopup" type="button" class="ui-button ui-button-orange" value="取消"/>

View File

@@ -19,7 +19,7 @@ module.exports = Vue.component('app-configure', {
twoWay: true,
required: true
},
uniqueProjects: {
unique: {
type: Object,
required: true
}
@@ -28,49 +28,39 @@ module.exports = Vue.component('app-configure', {
return {
name: '',
path: '',
submitError: '',
showPopup: false
}
},
methods: {
focus: function (event){
if (event.target.type === 'text') {
this.submitError = '';
}
},
appConfigure: function (command, configure){
ipc.send('app-configure', command, configure);
},
hidePopup: function (){
this.showPopup = false;
this.name = '';
this.path = '';
this.submitError = '';
// clean input
var base = this.$refs.base;
// clean error
this.$broadcast('reset-error');
base.$emit('reset-input');
base.$emit('reset-error');
},
add: function (){
this.$broadcast('submit');
var base = this.$refs.base;
if (this.name && this.path) {
if (this.uniqueProjects[this.name]) {
this.submitError = '项目已存在';
} else {
this.showPopup = false;
this.configure.projects.push({ name: this.name, path: this.path, env: [], command: [] });
if (base.isValid()) {
this.showPopup = false;
this.name = '';
this.path = '';
this.submitError = '';
this.configure.projects.push({
name: this.name,
path: this.path,
env: [],
command: []
});
// clean error
this.$broadcast('reset-error');
// send message
this.$dispatch('change-active', this.configure.projects.length - 1, true);
this.$dispatch('save-configure');
}
// clean input
base.$emit('reset-input');
// send message
this.$dispatch('change-active', this.configure.projects.length - 1, true);
this.$dispatch('save-configure');
}
}
},