Skip to content

Commit

Permalink
closer!
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Dec 20, 2023
1 parent 6c7e61d commit 3e3da24
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ angular.module('QuepidApp')

ctrl.refreshRatingsFromBook = function () {
//$uibModalInstance.close(ctrl.options);
bookSvc.refreshCaseRatingsFromBook(ctrl.theCase.caseNo, ctrl.theCase.bookId)
bookSvc.refreshCaseRatingsFromBook(ctrl.theCase.caseNo, ctrl.theCase.bookId, false)
.then(function() {
$scope.processingPrompt.inProgress = true;
$uibModalInstance.close();
Expand Down
7 changes: 7 additions & 0 deletions app/assets/javascripts/components/judgements/_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ <h3 class="modal-title">Judgements</h3>
&nbsp;&nbsp;<button ng-show="ctrl.populateBook" type="button" class="btn btn-sm btn-default" ng-click="isAdvancedPopulateConfigCollapsed = !isAdvancedPopulateConfigCollapsed">Advanced</button>

</label>
<br/>
<label>
<input id="sync-queries" type="checkbox" ng-model='ctrl.syncQueries' ng-disabled="ctrl.share.books.length === 0 || ctrl.share.teams.length === 0"> Sync missing Queries
<span class="glyphicon glyphicon-question-sign" aria-hidden="true" popover-trigger="'mouseenter'" popover-placement="right" uib-popover="Sync all the queries in the Case with those defined in the Book."></span>
</input>
</label>

<span ng-show="ctrl.populateBook">
<div uib-collapse="!isAdvancedPopulateConfigCollapsed">
Expand Down Expand Up @@ -118,6 +124,7 @@ <h3 class="modal-title">Judgements</h3>
<a class="btn btn-default pull-left" ng-click="ctrl.refreshRatingsFromBook()" ng-disabled="processingPrompt.inProgress || ctrl.populateBook || !ctrl.activeBookId || ctrl.share.acase.bookId !== ctrl.activeBookId" >
<i class="glyphicon glyphicon-refresh"></i>
Refresh ratings from book <i>{{ctrl.activeBookName}}</i>
<span ng-if="ctrl.syncQueries">and creating missing queries</span>
</a>

<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ angular.module('QuepidApp')
ctrl.refreshOnly = false;
ctrl.updateAssociatedBook = false;
ctrl.populateJudgements = false;
ctrl.syncQueries = false;

$rootScope.$watch('currentUser', function() {
if ( $rootScope.currentUser ) {
Expand Down Expand Up @@ -128,7 +129,7 @@ angular.module('QuepidApp')

ctrl.refreshRatingsFromBook = function () {
//$uibModalInstance.close(ctrl.options);
bookSvc.refreshCaseRatingsFromBook(ctrl.share.acase.caseNo, ctrl.activeBookId)
bookSvc.refreshCaseRatingsFromBook(ctrl.share.acase.caseNo, ctrl.activeBookId, ctrl.syncQueries)
.then(function() {
$scope.processingPrompt.inProgress = true;
$uibModalInstance.close();
Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/services/bookSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ angular.module('QuepidApp')
});
};

this.refreshCaseRatingsFromBook = function(caseId, bookId) {
// http POST api/books/<int:bookId>/case/<int:caseId>/refresh
this.refreshCaseRatingsFromBook = function(caseId, bookId, syncQueries) {
// http POST api/books/<int:bookId>/case/<int:caseId>/refresh?sync_queries=<bool:syncQueries>

var payload = {
};

return $http.put('api/books/' + bookId + '/cases/' + caseId + '/refresh', payload)
return $http.put('api/books/' + bookId + '/cases/' + caseId + '/refresh?sync_queries=' + syncQueries, payload)
.then(function(response) {
console.log('refreshed ratings' + response.data);
});
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/api/v1/books/refresh_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class RefreshController < Api::ApiController
before_action :check_case, only: [ :update ]

def update
@export = 'true' == params[:export]

service = RatingsManager.new(@book)
service.sync_ratings_for_case(@case)

Expand Down

0 comments on commit 3e3da24

Please sign in to comment.