Skip to content

Commit

Permalink
Apply suggestions from review
Browse files Browse the repository at this point in the history
  • Loading branch information
mbayopanda committed Aug 23, 2020
1 parent 857e8b3 commit f1dbc2a
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion client/src/i18n/en/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@
"QUANTITY": "Enter a quantity"
},
"SELECT": {
"TAGS":"Select tags to join",
"TAGS":"Select tags to add",
"PATIENT_TO_CONSIDER":"Select the patient to consider",
"ACCOUNT_REFERENCE" : "Select an Account Reference",
"ACCOUNT_REFERENCE_TYPE" : "Select an Account Reference Type",
Expand Down
4 changes: 2 additions & 2 deletions client/src/js/components/bhTagSelect/bhTagSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ function TagSelectController($rootScope, Tags, Notify) {
};

$ctrl.getTagColor = t => {
return t ? { color : t.color, 'font-size' : '14px' } : null;
return t ? { color : t.color } : null;
};

function loadTags() {
Tags.read(null)
Tags.read()
.then(tags => {
const identifiers = $ctrl.tagUuids.map(t => t.uuid);
$ctrl.tags = $ctrl.tagUuids.length ? tags.filter(t => identifiers.includes(t.uuid) === false) : tags;
Expand Down
8 changes: 4 additions & 4 deletions client/src/modules/stock/lots/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ function StockLotsController(
// serialize tag names for filters
vm.gridOptions.data = lots.map(lot => {
lot.tagNames = lot.tags.map(tag => tag.name).join(',');
lot.tags.forEach(addColorStyle);
return lot;
});

Expand All @@ -159,10 +160,9 @@ function StockLotsController(
.finally(toggleLoadingIndicator);
}

// returns a style for a given tag
vm.getTagColor = t => {
return t ? { color : t.color, 'font-size' : '14px' } : null;
};
function addColorStyle(tag) {
tag.style = { color : tag.color };
}

// remove a filter with from the filter object, save the filters and reload
vm.onRemoveFilter = function onRemoveFilter(key) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/stock/lots/templates/tags.cell.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="ui-grid-cell-contents">
<span ng-repeat="tag in row.entity.tags">
<i class="fa fa-circle" ng-style="grid.appScope.getTagColor(tag)"></i>
<i class="fa fa-circle" ng-style="tag.style"></i>
<span>{{tag.name}}</span>
</span>
</div>
4 changes: 2 additions & 2 deletions client/src/modules/tags/modal/createUpdate.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

<ui-select tagging name="color" ng-model="ModalCtrl.tags.color">
<ui-select-match placeholder="{{ 'FORM.PLACEHOLDERS.PICK_ONE' | translate }}">
<i class="fa fa-circle" ng-style="$select.selected.iconColor"></i>
<i class="fa fa-circle" ng-style="$select.selected.style"></i>
<span translate>{{$select.selected.name}}</span>
</ui-select-match>
<ui-select-choices repeat="color.value as color in ModalCtrl.colors | filter: {'name' :$select.search}">
<span><i class="fa fa-circle" ng-style="color.iconColor"></i> <span translate>{{ color.name }}</span></span>
<span><i class="fa fa-circle" ng-style="color.style"></i> <span translate>{{ color.name }}</span></span>
</ui-select-choices>
</ui-select>
</div>
Expand Down
20 changes: 9 additions & 11 deletions client/src/modules/tags/modal/createUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,27 @@ function TagsModalController(
data, TagsService, Notify, Instance, $rootScope, Colors,
) {
const vm = this;
vm.colors = Colors.list.map(e => {
e.iconColor = { color : e.value, 'font-size' : '14px' };
return e;
});
vm.colors = Colors.list.map(addIconStyle);
vm.close = Instance.close;
vm.submit = submit;

vm.tags = data ? angular.copy(data) : {};
vm.isCreation = !vm.tags.uuid;
vm.action = vm.isCreation ? 'FORM.LABELS.CREATE' : 'FORM.LABELS.UPDATE';

function addIconStyle(item) {
item.style = { color : item.value };
return item;
}

function submit(form) {
if (form.$invalid) {
return false;
}

if (typeof (vm.tags) === 'object') {
delete vm.tags.iconColor;
} else if (Array.isArray(vm.tags)) {
vm.tags.forEach(t => {
delete t.iconColor;
});
}
[].concat(vm.tags).forEach(tag => {
delete tag.style;
});

const operation = vm.isCreation
? TagsService.create(vm.tags)
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/tags/tags.ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function TagsController(Tags, Modal, Notify, uiGridConstants, $rootScope) {
Tags.read()
.then(tags => {
vm.gridOptions.data = tags.map(t => {
t.iconColor = { color : t.color, 'font-size' : '14px' };
t.style = { color : t.color };
return t;
});
})
Expand Down
3 changes: 2 additions & 1 deletion client/src/modules/tags/tags.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ TagService.$inject = ['PrototypeApiService', 'util', '$uibModal'];
*/
function TagService(Api, util, $uibModal) {
const baseUrl = '/tags/';
const tagKeys = ['uuid', 'name', 'color'];
const service = new Api(baseUrl);

service.types = new Api(baseUrl.concat('types/'));

const tagKeys = ['uuid', 'name', 'color'];
service.clean = tag => util.maskObjectFromKeys(tag, tagKeys);

service.createUpdateTagsModal = (tag) => {
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/tags/templates/name.cell.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div
class="ui-grid-cell-contents"
data-row="{{row.entity.name}}">
<i class="fa fa-circle" ng-style="row.entity.iconColor"></i>
<i class="fa fa-circle" ng-style="row.entity.style"></i>
<span translate>{{row.entity.name}}</span>
</div>
2 changes: 1 addition & 1 deletion server/models/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2193,7 +2193,7 @@ CREATE TABLE `service_fee_center` (
CREATE TABLE `tags`(
`uuid` BINARY(16) NOT NULL PRIMARY KEY,
`name` VARCHAR(100) NOT NULL,
`color` VARCHAR(20) NULL,
`color` VARCHAR(50) NULL,
UNIQUE KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARACTER SET = utf8mb4 DEFAULT COLLATE = utf8mb4_unicode_ci;

Expand Down

0 comments on commit f1dbc2a

Please sign in to comment.