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

@@ -24,76 +24,55 @@ module.exports = Vue.component('project-configure', {
type: Object,
required: true
},
uniqueProjects: {
unique: {
type: Object,
twoWay: true,
required: true
}
},
data: function (){
return {
nameError: '',
pathError: '',
submitError: '',
projectClone: null
clone: null
}
},
watch: {
project: function (project){
this.projectClone = util.clone(project);
this.reset();
this.clone = util.clone(project);
}
},
methods: {
focus: function (event){
if (event.target.type === 'text') {
this.submitError = '';
}
reset: function (){
// clean item input
var base = this.$refs.base;
var env = this.$refs.env;
var command = this.$refs.command;
base.$emit('reset-error');
env.$emit('reset-error');
command.$emit('reset-error');
env.$emit('reset-input');
command.$emit('reset-input');
},
edit: function (){
var name = this.projectClone.name;
var originName = this.project.name;
if (this.$refs.base.isValid()) {
this.show = false;
if (this.projectClone.name && this.projectClone.path) {
if (name !== originName && this.uniqueProjects[name]) {
this.submitError = '项目已存在';
} else {
this.show = false;
// send message
this.$dispatch('edit', util.clone(this.clone));
// clean error
this.submitError = '';
// send message
this.$dispatch('edit', util.clone(this.projectClone));
// clean error
this.$broadcast('reset-error');
// clean input
this.$broadcast('reset-item-input');
}
// clean item input
this.reset();
}
},
cancel: function (){
this.show = false;
this.submitError = '';
this.projectClone = util.clone(this.project);
this.clone = util.clone(this.project);
// clean error
this.$broadcast('reset-error');
// clean input
this.$broadcast('reset-item-input');
}
},
events: {
'configure-refresh': function (){
this.submitError = '';
// clean error
this.$broadcast('reset-error');
// clean input
this.$broadcast('reset-item-input');
// clean item input
this.reset();
}
},
created: function (){
this.projectClone = util.clone(this.project);
this.clone = util.clone(this.project);
}
});

View File

@@ -1,5 +1,5 @@
<div v-show="show" class="ui-project-setting">
<form @submit.prevent="edit" @focusin="focus">
<form @submit.prevent="edit">
<div class="ui-control-bar fn-clear">
<div class="fn-right">
<input type="submit" class="ui-button" value="确认"/>
@@ -7,16 +7,31 @@
</div>
</div>
<div class="ui-project-configure">
<div v-show="submitError" class="ui-submit-tips">{{ submitError }}</div>
<ul>
<li is="project-base" :name.sync="projectClone.name" :path.sync="projectClone.path"></li>
<li
v-ref:base
is="project-base"
:name.sync="clone.name"
:path.sync="clone.path"
:unique="unique">
</li>
<li class="ui-sub-item">
<label>环境变量:</label>
<dynamic-item name-label="变量名" value-label="变量值" :items.sync="projectClone.env"></dynamic-item>
<dynamic-item
v-ref:env
name-label="变量名"
value-label="变量值"
:items.sync="clone.env">
</dynamic-item>
</li>
<li id="add-cmd" class="ui-sub-item">
<label>项目命令:</label>
<dynamic-item name-label="名称" value-label="命令" :items.sync="projectClone.command"></dynamic-item>
<dynamic-item
v-ref:command
name-label="名称"
value-label="命令"
:items.sync="clone.command">
</dynamic-item>
</li>
</ul>
</div>