Skip to content

Commit

Permalink
Convert custom search flag from Assets-only to Exclude-assets
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcameron committed Apr 12, 2022
1 parent f63e343 commit 1f86499
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
1 change: 1 addition & 0 deletions client/src/i18n/en/asset.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"ASSIGN_TO" : "Assign to",
"DETAILS" : "Asset Details",
"DOCUMENT" : "Assignment Document",
"EXCLUDE_ASSETS" : "Exclude assets",
"LAST_SCAN_DATE" : "Last Scan Date",
"NEW_ASSET_SCAN" : "New Asset Scan",
"NEW_REQUIRED_INVENTORY_SCAN" : "New Required Inventory Scan",
Expand Down
1 change: 1 addition & 0 deletions client/src/i18n/fr/asset.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"ASSIGN_TO" : "Assigner à",
"DETAILS" : "Détail de l'actif",
"DOCUMENT" : "Document",
"EXCLUDE_ASSETS" : "Exclure les actifs",
"LAST_SCAN_DATE" : "Date du dernier scan",
"NEW_ASSET_SCAN" : "Nouveau scan d'un actif",
"NEW_REQUIRED_INVENTORY_SCAN" : "Nouvelle scan d'inventaire obligatoire",
Expand Down
25 changes: 13 additions & 12 deletions client/src/modules/stock/lots/modals/search.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,6 @@
</div>
</div>

<!-- is_asset -->
<div class="form-group">
<div class="checkbox">
<label>
<input type="checkbox"
ng-model="$ctrl.searchQueries.is_asset"
ng-true-value="1" ng-false-value="0">
<span translate>FORM.LABELS.ASSETS_ONLY</span>
</label>
</div>
</div>

<!-- reference_number -->
<div class="form-group">
<label class="control-label" translate>FORM.LABELS.REFERENCE_NUMBER</label>
Expand Down Expand Up @@ -103,6 +91,19 @@
<bh-clear on-clear="$ctrl.clear('is_expiry_risk')"></bh-clear>
</bh-yes-no-radios>

<!-- is_asset -->
<div class="form-group">
<div class="checkbox">
<label>
<input type="checkbox"
ng-model="$ctrl.excludeAssets"
ng-change="$ctrl.onExcludeAssets()"
ng-true-value="1" ng-false-value="0">
<span translate>ASSET.EXCLUDE_ASSETS</span>
</label>
</div>
</div>

<!-- tags -->
<bh-tag-select
tag-uuids="$ctrl.searchQueries.tags"
Expand Down
14 changes: 14 additions & 0 deletions client/src/modules/stock/lots/modals/search.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ function SearchLotsModalController(data, util, Store, Instance, Periods, Stock,
// assign already defined custom filters to searchQueries object
vm.searchQueries = util.maskObjectFromKeys(data, searchQueryOptions);

// Set the excludeAssets flag based on the existing custom search filter
vm.excludeAssets = 0;
if ('is_asset' in vm.searchQueries && !vm.searchQueries.is_asset) {
vm.excludeAssets = 1;
}

// default filter period - directly write to changes list
vm.onSelectPeriod = function onSelectPeriod(period) {
const periodFilters = Periods.processFilterChanges(period);
Expand All @@ -51,6 +57,14 @@ function SearchLotsModalController(data, util, Store, Instance, Periods, Stock,
displayValues.inventory_uuid = inventory.label;
};

vm.onExcludeAssets = function onExcludeAssets() {
if (vm.excludeAssets) {
vm.searchQueries.is_asset = 0;
} else {
vm.clear('is_asset');
}
};

// include/exclude empty lots
vm.setIncludeEmptyLot = (value) => {
vm.defaultQueries.includeEmptyLot = value;
Expand Down

0 comments on commit 1f86499

Please sign in to comment.