From 5950b4827671573553eae9d33c09596bd7de0aa6 Mon Sep 17 00:00:00 2001 From: Nuintun Date: Fri, 20 Nov 2015 16:08:44 +0800 Subject: [PATCH] update files --- index.html | 1 + static/css/index.css | 7 +++- static/js/app/index.js | 5 ++- .../app-configure/app-configure.html | 19 ++-------- static/js/components/app-configure/index.js | 31 +++++++++++++++- static/js/components/dynamic-item/index.js | 6 +++ static/js/components/project-base/index.js | 11 +++++- .../project-configure/project-configure.html | 37 +++++++++++++++++++ 8 files changed, 96 insertions(+), 21 deletions(-) diff --git a/index.html b/index.html index fb2a255..86b6deb 100644 --- a/index.html +++ b/index.html @@ -49,6 +49,7 @@
+
项目已经存在
-
+
{{ submitError }}
+
    -
  • - - -
  • -
  • - - asdasdasdsa -
  • - -
  • - - asdasdasdsa -
  • +
  • diff --git a/static/js/components/app-configure/index.js b/static/js/components/app-configure/index.js index 90d2ca1..41d46d9 100644 --- a/static/js/components/app-configure/index.js +++ b/static/js/components/app-configure/index.js @@ -20,6 +20,10 @@ module.exports = Vue.component('app-configure', { }, data: function (){ return { + name: '', + path: '', + _cached: {}, + submitError: '', popup: false } }, @@ -29,9 +33,34 @@ module.exports = Vue.component('app-configure', { }, popupToggle: function (){ this.popup = !this.popup; + + if (!this.popup) { + this.submitError = ''; + this.$broadcast('clean-error'); + } }, addProject: function (){ - + this.$broadcast('submit'); + + if (this.name && this.path) { + if (this.$data._cached[this.name]) { + this.submitError = '项目已存在'; + } else { + this.popup = false; + this.configure.projects.push({ name: this.name, path: this.path }); + this.$data._cached[this.name] = true; + + // clean imput + this.name = ''; + this.path = ''; + this.submitError = ''; + } + } } + }, + created: function (){ + this.configure.projects.forEach(function (project){ + this.$data._cached[project.name] = true; + }, this); } }); diff --git a/static/js/components/dynamic-item/index.js b/static/js/components/dynamic-item/index.js index 83d078e..4c9d95e 100644 --- a/static/js/components/dynamic-item/index.js +++ b/static/js/components/dynamic-item/index.js @@ -82,6 +82,12 @@ module.exports = Vue.component('dynamic-item', { delete this.$data._cached[item.name]; } }, + events: { + 'clean-error': function (){ + this.nameError = ''; + this.valueError = ''; + } + }, created: function (){ this.items.forEach(function (item){ this.$data._cached[item.name] = true; diff --git a/static/js/components/project-base/index.js b/static/js/components/project-base/index.js index fa19278..e4bd219 100644 --- a/static/js/components/project-base/index.js +++ b/static/js/components/project-base/index.js @@ -8,7 +8,7 @@ var fs = require('fs'); var path = require('path'); var Vue = require('../../vue/vue'); -module.exports = Vue.component('app-configure', { +module.exports = Vue.component('project-base', { template: fs.readFileSync(path.join(__dirname, 'project-base.html')).toString(), props: { name: { @@ -28,7 +28,16 @@ module.exports = Vue.component('app-configure', { pathError: '' }; }, + methods: { + focus: function (key){ + this[key] = ''; + } + }, events: { + 'clean-error': function (){ + this.nameError = ''; + this.pathError = ''; + }, 'submit': function (){ this.name = this.name.trim(); this.path = this.path.trim(); diff --git a/static/js/components/project-configure/project-configure.html b/static/js/components/project-configure/project-configure.html index e69de29..d32b70d 100644 --- a/static/js/components/project-configure/project-configure.html +++ b/static/js/components/project-configure/project-configure.html @@ -0,0 +1,37 @@ +
    + +
    +
    + + +
    +
    +
    +
      +
    • + + +
    • +
    • + + 项目名称不能为空 +
    • +
    • + +
    • +
    • + + 项目路径不能为空 +
    • +
    • + + +
    • +
    • + + +
    • +
    +
    + +
    \ No newline at end of file