From f4fe396b048535e6e37aa714a39af242741a4baa Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Thu, 19 Jul 2018 02:53:30 +0200 Subject: [PATCH] wip interface --- static/js/ckhome.js | 63 +++++++++++++++++++----- static/views/home.html | 106 ++++++++++++++++++---------------------- static/views/items.html | 8 +-- static/views/rooms.html | 4 +- static/views/tags.html | 4 +- static/views/users.html | 4 +- 6 files changed, 110 insertions(+), 79 deletions(-) diff --git a/static/js/ckhome.js b/static/js/ckhome.js index ce03c76..d4ec379 100644 --- a/static/js/ckhome.js +++ b/static/js/ckhome.js @@ -81,8 +81,10 @@ angular.module("CheckHomeApp") else this.room.$update(); } - $scope.delRoom = function() { - this.room.$remove(); + $scope.delRoom = function(rk) { + this.room.$delte().then(function() { + $scope.room.splice(rk, 1); + }); } }) .controller("ItemsRoomController", function($scope, ItemRoom) { @@ -102,19 +104,46 @@ angular.module("CheckHomeApp") else this.item.$update(); } - $scope.delItem = function() { - this.item.$remove(); + $scope.delItem = function(ik) { + this.item.$delete().then(function() { + $scope.items.splice(ik, 1); + }); } }) .controller("ChecksItemController", function($scope, ItemChecks) { + $scope.ncomment = ""; $scope.checks = ItemChecks.query({itemId: $scope.item.id}); + $scope.min_checks = function() { + function state2int(state) { + switch(state) { + case "yes": + return 4; + case "yesbut": + return 3; + case "nobut": + return 2; + case "no": + return 1; + default: + return 5; + } + } + var min = "N/A"; + angular.forEach($scope.checks, function(check) { + if (state2int(min) > state2int(check["passed"])) + min = check["passed"]; + }); + return min; + } $scope.newCheck = function(passed) { var c = new ItemChecks(); c.passed = passed; + c.comment = $scope.ncomment; c.$save({itemId: $scope.item.id}, function(res) { + $scope.ncomment = ""; $scope.checks.push(res) - }) + }); } $scope.checkOk = function() { $scope.newCheck("yes"); @@ -128,6 +157,12 @@ angular.module("CheckHomeApp") $scope.checkKo = function() { $scope.newCheck("no"); } + + $scope.delCheck = function(ck) { + this.check.$delete({itemId: $scope.item.id}).then(function() { + $scope.checks.splice(ck, 1); + }); + } }) .controller("TagsController", function($scope, Tag) { $scope.tags = Tag.query(); @@ -146,8 +181,10 @@ angular.module("CheckHomeApp") else this.tag.$update(); } - $scope.delTag = function() { - this.tag.$remove(); + $scope.delTag = function(tk) { + this.tag.$delete().then(function() { + $scope.tags.splice(tk, 1); + }); } }) .controller("TagsItemController", function($scope, TagsItem) { @@ -170,8 +207,10 @@ angular.module("CheckHomeApp") else this.tag.$update(); } - $scope.delItemTag = function() { - this.tag.$remove({itemId: $scope.item.id, tagId: this.tag.id}); + $scope.delItemTag = function(tk) { + this.tag.$delete({itemId: $scope.item.id, tagId: this.tag.id}).then(function() { + $scope.itags.splice(tk, 1); + }); } }) .controller("UsersController", function($scope, User) { @@ -195,7 +234,9 @@ angular.module("CheckHomeApp") else this.user.$update(); } - $scope.delUser = function() { - this.user.$remove(); + $scope.delUser = function(uk) { + this.user.$delete().then(function(){ + $scope.users.splice(uk, 1); + }); } }); diff --git a/static/views/home.html b/static/views/home.html index 31e5be5..1419fb3 100644 --- a/static/views/home.html +++ b/static/views/home.html @@ -1,70 +1,60 @@
-

{{room.label}}

-
-
-
-
- - -
+

+ {{room.label}} +

+ +
+
+
+ + + + + {{item.label}}
-
- {{ checks }} -

+
+
+

+
+
    +
  • + OK + OK + KO + KO + + + + {{check.comment}} +
  • +
- -
    -
  • - -
      -
    • - - {{ item.label }} - - {{ tag.label }} - - - - - - - - - - Add - - - -
      - {{ item.description }} -
      -
      - - -
      - -
      -
    • -
    • - -
    • -
    -
  • -
+
+ + +
+
+
diff --git a/static/views/items.html b/static/views/items.html index 58302db..742a2e7 100644 --- a/static/views/items.html +++ b/static/views/items.html @@ -2,14 +2,14 @@