wip interface

This commit is contained in:
nemunaire 2018-07-19 02:53:30 +02:00
parent 2a64795e59
commit f4fe396b04
6 changed files with 110 additions and 79 deletions

View File

@ -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);
});
}
});

View File

@ -1,70 +1,60 @@
<div ng-repeat="room in rooms" ng-controller="ItemsRoomController">
<h2>{{room.label}}</h2>
<div class="card-columns" style="column-count: 4;">
<div class="card" ng-repeat="item in items">
<div class="card-header form-check">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="customCheck1">
<label class="custom-control-label" for="customCheck1" ng-bind="item.label"></label>
</div>
<h2>
{{room.label}}
</h2>
<div class="card" ng-repeat="item in items" ng-controller="ChecksItemController">
<div class="card-header row" ng-class="{'bg-success': min_checks() == 'yes', 'bg-info': min_checks() == 'yesbut', 'bg-warning': min_checks() == 'nobut', 'bg-danger': min_checks() == 'no', 'bg-secondary': min_checks() == 'N/A'}" ng-controller="TagsItemController">
<div class="col-md">
<span ng-if="min_checks() == 'yes'" class="badge badge-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></span>
<span ng-if="min_checks() == 'yesbut'" class="badge badge-info"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></span>
<span ng-if="min_checks() == 'nobut'" class="badge badge-warning"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></span>
<span ng-if="min_checks() == 'no'" class="badge badge-danger"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></span>
<strong>{{item.label}}</strong>
</div>
<div class="card-body" ng-controller="ChecksItemController">
{{ checks }}
<p class="card-text" ng-if="item.description" ng-bind="item.description"></p>
<div class="col-md text-right">
<button type="button" class="btn btn-outline-success" ng-click="checkOk()">OK</button>
<button type="button" class="btn btn-outline-info" ng-click="checkMok()">OK, mais&hellip;</button>
<button type="button" class="btn btn-outline-warning" ng-click="checkMko()">KO, mais&hellip;</button>
<button type="button" class="btn btn-outline-danger" ng-click="checkKo()">KO</button>
</div>
</div>
<div class="card-body">
<p class="card-text" ng-if="item.description" ng-bind="item.description"></p>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item" ng-repeat="(ck, check) in checks">
<span ng-if="check.passed == 'yes'" class="badge badge-success">OK</span>
<span ng-if="check.passed == 'yesbut'" class="badge badge-info">OK</span>
<span ng-if="check.passed == 'nobut'" class="badge badge-warning">KO</span>
<span ng-if="check.passed == 'no'" class="badge badge-danger">KO</span>
<a ng-click="delCheck(ck)" class="float-right" ng-if="!check.id_user">
<span class="glyphicon glyphicon-minus" aria-hidden="true"></span>
</a>
{{check.comment}}
</li>
</ul>
</div>
</div>
<ul ng-controller="TagsController">
<li ng-repeat="room in rooms">
<span ng-bind="room.label"></span>
<ul ng-controller="ItemsRoomController">
<li ng-repeat="item in items">
<span ng-if="!item.edit" ng-controller="TagsItemController">
<strong>{{ item.label }}</strong>
<span class="badge badge-secondary" ng-repeat="tag in itags">
<span ng-if="!tag.edit">{{ tag.label }}</span>
<select ng-options="tag.id as tag.label for tag in tags track by tag.id" ng-model="tag.val" ng-if="tag.edit">
</select>
<a ng-click="delItemTag()" ng-if="!tag.edit">
<span class="glyphicon glyphicon-minus" aria-hidden="true"></span>
</a>
<a ng-click="saveItemTag()" ng-if="tag.edit">
<span class="glyphicon glyphicon-check" aria-hidden="true"></span>
</a>
</span>
<a class="badge badge-secondary" ng-click="newItemTag()">
Add
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
</a>
<button type="button" class="btn btn-sm btn-primary" ng-click="editItem()" ng-if="!item.edit">
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
</button>
<button type="button" class="btn btn-sm btn-danger" ng-click="delItem()" ng-if="!item.edit">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
</button><br>
{{ item.description }}
</span>
<form ng-if="item.edit" ng-submit="saveItem()">
<input ng-model="item.label">
<button type="submit" class="btn btn-sm btn-success">
<span class="glyphicon glyphicon-check" aria-hidden="true"></span>
</button>
<br>
<textarea ng-model="item.description"></textarea>
</form>
</li>
<li>
<button type="button" class="btn btn-sm btn-dark" ng-click="newItem()">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
<div class="modal fade" id="commentModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="commentModalLabel">New message</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</li>
</ul>
</li>
</ul>
</div>
<div class="modal-body">
<form>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Send message</button>
</div>
</div>
</div>
</div>

View File

@ -2,14 +2,14 @@
<li ng-repeat="room in rooms">
<span ng-bind="room.label"></span>
<ul ng-controller="ItemsRoomController">
<li ng-repeat="item in items">
<li ng-repeat="(ik, item) in items">
<span ng-if="!item.edit" ng-controller="TagsItemController">
<strong>{{ item.label }}</strong>
<span class="badge badge-secondary" ng-repeat="tag in itags">
<span class="badge badge-secondary" ng-repeat="(tk, tag) in itags">
<span ng-if="!tag.edit">{{ tag.label }}</span>
<select ng-options="tag.id as tag.label for tag in tags track by tag.id" ng-model="tag.val" ng-if="tag.edit">
</select>
<a ng-click="delItemTag()" ng-if="!tag.edit">
<a ng-click="delItemTag(tk)" ng-if="!tag.edit">
<span class="glyphicon glyphicon-minus" aria-hidden="true"></span>
</a>
<a ng-click="saveItemTag()" ng-if="tag.edit">
@ -23,7 +23,7 @@
<button type="button" class="btn btn-sm btn-primary" ng-click="editItem()" ng-if="!item.edit">
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
</button>
<button type="button" class="btn btn-sm btn-danger" ng-click="delItem()" ng-if="!item.edit">
<button type="button" class="btn btn-sm btn-danger" ng-click="delItem(ik)" ng-if="!item.edit">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
</button><br>
{{ item.description }}

View File

@ -1,10 +1,10 @@
<ul>
<li ng-repeat="room in rooms">
<li ng-repeat="(rk, room) in rooms">
<span ng-if="!room.edit" ng-bind="room.label"></span>
<button type="button" class="btn btn-sm btn-primary" ng-click="editRoom()" ng-if="!room.edit">
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
</button>
<button type="button" class="btn btn-sm btn-danger" ng-click="delRoom()" ng-if="!room.edit">
<button type="button" class="btn btn-sm btn-danger" ng-click="delRoom(rk)" ng-if="!room.edit">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
</button>
<form ng-if="room.edit" ng-submit="saveRoom()">

View File

@ -1,10 +1,10 @@
<ul>
<li ng-repeat="tag in tags">
<li ng-repeat="(tk, tag) in tags">
<span ng-if="!tag.edit" ng-bind="tag.label"></span>
<button type="button" class="btn btn-sm btn-primary" ng-click="editTag()" ng-if="!tag.edit">
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
</button>
<button type="button" class="btn btn-sm btn-danger" ng-click="delTag()" ng-if="!tag.edit">
<button type="button" class="btn btn-sm btn-danger" ng-click="delTag(tk)" ng-if="!tag.edit">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
</button>
<form ng-if="tag.edit" ng-submit="saveTag()">

View File

@ -1,10 +1,10 @@
<ul>
<li ng-repeat="user in users">
<li ng-repeat="(uk, user) in users">
<span ng-if="!user.edit" ng-bind="user.username"></span>
<button type="button" class="btn btn-sm btn-primary" ng-click="editUser()" ng-if="!user.edit">
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
</button>
<button type="button" class="btn btn-sm btn-danger" ng-click="delUser()" ng-if="!user.edit">
<button type="button" class="btn btn-sm btn-danger" ng-click="delUser(uk)" ng-if="!user.edit">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
</button>
<form ng-if="user.edit" ng-submit="saveUser()">