Various tweaks

This commit is contained in:
Dobie Wollert
2015-10-14 02:51:05 -07:00
parent 68b2c8114b
commit 0e5db1c9ee
9 changed files with 48 additions and 9 deletions

View File

@ -73,6 +73,14 @@ function checkListsControllerFactory(isEdit) {
}
}
function moveUpField(index) {
$scope.model.fields.splice(index - 1, 0, $scope.model.fields.splice(index, 1)[0]);
}
function moveDownField(index) {
$scope.model.fields.splice(index + 1, 0, $scope.model.fields.splice(index, 1)[0]);
}
function save() {
if (isEdit) {
CheckLists.update({id: $scope.model._id}, $scope.model, function() {
@ -87,6 +95,8 @@ function checkListsControllerFactory(isEdit) {
$scope.addField = addField;
$scope.removeField = removeField;
$scope.moveUpField = moveUpField;
$scope.moveDownField = moveDownField;
$scope.save = save;
$scope.isEdit = isEdit;

View File

@ -257,4 +257,13 @@ angular.module('biomed')
$location.path("/deviceTypes/");
});
};
$scope.delete = function() {
$scope.model.images = Object.keys(images);
$scope.model.deleted = true;
DeviceTypes.update({id: $scope.model._id}, $scope.model, function(result) {
$location.path("/deviceTypes/");
});
};
})

View File

@ -104,6 +104,20 @@ function devicesControllerFactory(isEdit) {
});
}
function destroy() {
$scope.model.deleted = true;
Devices.update({id: $scope.model._id}, $scope.model, function() {
$location.path("/clients/" + $scope.model.client);
});
}
function restore() {
$scope.model.deleted = false;
Devices.update({id: $scope.model._id}, $scope.model, function() {
$location.path("/clients/" + $scope.model.client);
});
}
var hashids = new Hashids("biomed");
var search = $location.search();
@ -121,6 +135,8 @@ function devicesControllerFactory(isEdit) {
$scope.create = create;
$scope.update = update;
$scope.destroy = destroy;
$scope.restore = restore;
deviceTypePickerFactory('category', 'Device Type');
deviceTypePickerFactory('make', 'Make');

View File

@ -57,7 +57,9 @@
</div>
</div>
<div class="form-actions">
<button ng-click="removeField($index)" ng-disabled="model.fields.length <= 1" class="btn" type="button">Remove Field</button>
<button ng-click="removeField($index)" ng-disabled="model.fields.length <= 1" class="btn" type="button">Remove</button>
<button ng-click="moveUpField($index)" ng-disabled="model.fields.length <= 1 || $index == 0" class="btn" type="button">Move Up</button>
<button ng-click="moveDownField($index)" ng-disabled="model.fields.length <= 1 || $index == model.fields.length - 1" class="btn" type="button">Move Down</button>
</div>
</div>
</div>

View File

@ -299,8 +299,8 @@
<thead>
<tr>
<th style="width: 7%">Control #</th>
<th style="width: 6%">Category</th>
<th style="width: 5%">Make</th>
<th style="width: 6%">Device</th>
<th style="width: 5%">Manufacturer</th>
<th style="width: 5%">Model</th>
<th style="width: 5%">Serial No.</th>
<th style="width: 8%">Purchase Date</th>

View File

@ -101,6 +101,7 @@
<div class="section-label">&nbsp;</div>
<div class="section-container">
<button ng-click="save()" ng-disabled="form.$invalid" type="button" class="btn btn-primary">Save</button>
<button ng-click="delete()" ng-disabled="form.$invalid" ng-show="accountHasPermission('system.admin')" type="button" class="btn btn-danger">Remove</button>
</div>
</div>
</form>

View File

@ -20,8 +20,8 @@
<table class="biomed-table" infinite-scroll="addItems()" can-load="canLoad" threshold="300">
<thead>
<tr>
<th style="width: 33%" ng-class="selectedCls('category')" ng-click="changeSorting('category')">Device Type</th>
<th style="width: 33%" ng-class="selectedCls('make')" ng-click="changeSorting('make')">Make</th>
<th style="width: 33%" ng-class="selectedCls('category')" ng-click="changeSorting('category')">Device</th>
<th style="width: 33%" ng-class="selectedCls('make')" ng-click="changeSorting('make')">Manufacturer</th>
<th style="width: 33%" ng-class="selectedCls('model')" ng-click="changeSorting('model')">Model</th>
<th></th>
</tr>

View File

@ -12,13 +12,13 @@
<div class="section-container">
<div class="form-editor">
<div class="control-group">
<label class="control-label">Category</label>
<label class="control-label">Device</label>
<div class="controls">
<input type="hidden" ng-model="deviceTypes.category.picker" ui-select2="deviceTypes.category.opts" />
</div>
</div>
<div class="control-group">
<label class="control-label">Make</label>
<label class="control-label">Manufacturer</label>
<div class="controls">
<input type="hidden" ng-model="deviceTypes.make.picker" ui-select2="deviceTypes.make.opts" />
</div>

View File

@ -15,13 +15,13 @@
<div class="section-container">
<div class="form-editor">
<div class="control-group">
<label class="control-label">Category</label>
<label class="control-label">Device</label>
<div class="controls">
<input type="hidden" ng-model="deviceTypes.category.picker" ui-select2="deviceTypes.category.opts" />
</div>
</div>
<div class="control-group">
<label class="control-label">Make</label>
<label class="control-label">Manufacturer</label>
<div class="controls">
<input type="hidden" ng-model="deviceTypes.make.picker" ui-select2="deviceTypes.make.opts" />
</div>
@ -167,6 +167,7 @@
<div class="section-label">&nbsp;</div>
<div class="section-container">
<button ng-click="update()" ng-disabled="form.$invalid || !model.deviceType" type="button" class="btn btn-primary">Save</button>
<button ng-click="destroy()" ng-show="accountHasPermission('system.admin')" type="button" class="btn btn-danger">Remove</button>
</div>
</div>
</form>