Skip to content

Commit

Permalink
feat: post-property-import btn to import meters if tab exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Lara committed Jun 17, 2021
1 parent 6d687a0 commit 79eee3f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
17 changes: 17 additions & 0 deletions seed/static/seed/js/controllers/data_upload_modal_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,18 @@ angular.module('BE.seed.controller.data_upload_modal', [])
});
};

$scope.reuse_import_file_to_import_meters = function () {
dataset_service.reuse_inventory_file_for_meters($scope.dataset.import_file_id).then(function (data) {
$scope.dataset.import_file_id = data.import_file_id;
$scope.uploader.progress = 50;
$scope.uploader.status_message = 'analyzing file';
uploader_service
.pm_meters_preview($scope.dataset.import_file_id, $scope.organization.org_id)
.then(present_parsed_meters_confirmation)
.catch(present_meter_import_error);
})
}

/**
* save_raw_assessed_data: saves Assessed data
*
Expand Down Expand Up @@ -639,6 +651,11 @@ angular.module('BE.seed.controller.data_upload_modal', [])
$scope.step_10_file_message = 'Warning(s)/Error(s) occurred while processing the file(s):\n' + JSON.stringify(progress_data.file_info, null, 2);
}

// Toggle a meter import button if the imported file also has a meters tab
dataset_service.check_meters_tab_exists($scope.dataset.import_file_id).then(function(result) {
$scope.import_file_reusable_for_meters = result;
});

// If merges against existing exist, provide slightly different feedback
if ($scope.property_merges_against_existing + $scope.tax_lot_merges_against_existing > 0) {
$scope.step.number = 8;
Expand Down
20 changes: 20 additions & 0 deletions seed/static/seed/js/services/dataset_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,25 @@ angular.module('BE.seed.service.dataset', []).factory('dataset_service', [
});
};

dataset_service.check_meters_tab_exists = function (file_id) {
debugger;
return $http.get('/api/v3/import_files/' + file_id + '/check_meters_tab_exists', {
params: {
organization_id: user_service.get_organization().id
}
}).then(function (response) {
return response.data
});
}

dataset_service.reuse_inventory_file_for_meters = function (file_id) {
return $http.post('/api/v3/import_files/reuse_inventory_file_for_meters/', {
import_file_id: file_id,
organization_id: user_service.get_organization().id
}).then(function (response) {
return response.data;
});
};

return dataset_service;
}]);
6 changes: 6 additions & 0 deletions seed/static/seed/partials/data_upload_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ <h5>Use Case Warnings</h5>
<div class="row text-center">
<button type="button" class="btn btn-primary col-sm-6 center-block" ng-click="goto_step(2)" translate>Add another file</button>
</div>
<div class="row text-center" ng-if="import_file_reusable_for_meters">
<button type="button" class="btn btn-primary col-sm-6 center-block" ng-click="reuse_import_file_to_import_meters(file_id)" translate>Import Meters from the same file</button>
</div>
<div class="row text-center">
<button type="button" class="btn btn-primary col-sm-6 center-block" ng-click="view_my_properties()" translate>View my properties</button>
</div>
Expand All @@ -415,6 +418,9 @@ <h5>Use Case Warnings</h5>
<div class="row text-center" ng-hide="step_10_mapquest_api_error">
<button id="view-buildings" type="button" class="btn btn-primary col-sm-6 center-block" ng-click="view_my_properties()" translate>View my properties</button>
</div>
<div class="row text-center" ng-if="import_file_reusable_for_meters">
<button type="button" class="btn btn-primary col-sm-6 center-block" ng-click="reuse_import_file_to_import_meters(file_id)" translate>Import Meters from the same file</button>
</div>
<div class="row text-center" ng-if="step_10_mapquest_api_error">
<button type="button" class="btn btn-primary col-sm-6 center-block" ng-click="reset_mapquest_api_key()" translate>Update MapQuest API key</button>
</div>
Expand Down

0 comments on commit 79eee3f

Please sign in to comment.