Merge pull request #2437 from 0xF013/fix/17263-query-save-button-state

fix save button state
pull/2330/merge
Alex Coles 10 years ago
commit 38ebcda301
  1. 5
      frontend/app/models/query.js
  2. 5
      frontend/app/services/query-service.js
  3. 6
      frontend/app/work_packages/controllers/menus/column-context-menu-controller.js
  4. 14
      frontend/app/work_packages/controllers/menus/settings-dropdown-menu-controller.js
  5. 13
      frontend/app/work_packages/controllers/work-packages-list-controller.js
  6. 1
      frontend/app/work_packages/directives/query-filter-directive.js

@ -188,6 +188,7 @@ module.exports = function(Filter, Sortation, UrlParamsHelper, INITIALLY_SELECTED
},
setRawFilters: function(filters) {
this.dirty = true;
if (filters){
var self = this;
@ -291,6 +292,7 @@ module.exports = function(Filter, Sortation, UrlParamsHelper, INITIALLY_SELECTED
},
addFilter: function(filterName, options) {
this.dirty = true;
var filter = this.getFilterByName(filterName);
if (filter) {
@ -304,6 +306,7 @@ module.exports = function(Filter, Sortation, UrlParamsHelper, INITIALLY_SELECTED
},
removeFilter: function(filterName) {
this.dirty = true;
this.filters.splice(this.getFilterNames().indexOf(filterName), 1);
},
@ -354,7 +357,7 @@ module.exports = function(Filter, Sortation, UrlParamsHelper, INITIALLY_SELECTED
},
isDirty: function() {
return this.isNew() || this.dirty;
return this.dirty;
},
hasName: function() {

@ -190,6 +190,7 @@ module.exports = function(Query, Sortation, $http, PathHelper, $q, AVAILABLE_WOR
setGroupBy: function(groupBy) {
query.setGroupBy(groupBy);
query.dirty = true;
},
getSelectedColumns: function() {
@ -197,6 +198,7 @@ module.exports = function(Query, Sortation, $http, PathHelper, $q, AVAILABLE_WOR
},
setSelectedColumns: function(selectedColumnNames) {
query.dirty = true;
var currentColumns = this.getSelectedColumns();
this.hideColumns(currentColumns.map(function(column) { return column.name; }));
@ -316,7 +318,8 @@ module.exports = function(Query, Sortation, $http, PathHelper, $q, AVAILABLE_WOR
saveQuery: function() {
var url = query.project_id ? PathHelper.apiProjectQueryPath(query.project_id, query.id) : PathHelper.apiQueryPath(query.id);
return QueryService.doQuery(url, query.toUpdateParams(), 'PUT', function(response){
return QueryService.doQuery(url, query.toUpdateParams(), 'PUT', function(response) {
query.dirty = false;
QueryService.fetchAvailableGroupedQueries(query.project_id);
return angular.extend(response.data, { status: { text: I18n.t('js.notice_successful_update') }} );

@ -40,27 +40,33 @@ module.exports = function($scope, ColumnContextMenu, I18n, QueryService, WorkPac
$scope.groupBy = function(columnName) {
QueryService.getQuery().groupBy = columnName;
QueryService.getQuery().dirty = true;
};
$scope.sortAscending = function(columnName) {
WorkPackagesTableService.sortBy(columnName || 'id', 'asc');
QueryService.getQuery().dirty = true;
};
$scope.sortDescending = function(columnName) {
WorkPackagesTableService.sortBy(columnName || 'id', 'desc');
QueryService.getQuery().dirty = true;
};
$scope.moveLeft = function(columnName) {
WorkPackagesTableHelper.moveColumnBy($scope.columns, columnName, -1);
QueryService.getQuery().dirty = true;
};
$scope.moveRight = function(columnName) {
WorkPackagesTableHelper.moveColumnBy($scope.columns, columnName, 1);
QueryService.getQuery().dirty = true;
};
$scope.hideColumn = function(columnName) {
ColumnContextMenu.close();
QueryService.hideColumns(new Array(columnName));
QueryService.getQuery().dirty = true;
};
$scope.insertColumns = function() {

@ -40,7 +40,10 @@ module.exports = function(
});
$scope.saveQuery = function(event){
if($scope.query.isNew()){
if (!$scope.query.isDirty()) {
return;
}
if($scope.query.isNew()) {
if( allowQueryAction(event, 'create') ){
$scope.$emit('hideAllDropdowns');
saveModal.activate();
@ -140,8 +143,13 @@ module.exports = function(
};
$scope.saveQueryInvalid = function() {
return (!$scope.query.isDirty() && AuthorisationService.cannot('query', 'update')) ||
($scope.query.isNew() && AuthorisationService.cannot('query', 'create'));
return (!$scope.query.isDirty()) ||
(
$scope.query.isDirty() &&
!$scope.query.isNew() &&
AuthorisationService.cannot('query', 'update')
) ||
($scope.query.isNew() && AuthorisationService.cannot('query', 'create'));
};
function preventNewQueryAction(event){

@ -59,7 +59,9 @@ module.exports = function($scope, $rootScope, $state, $location, latestTab,
}
$scope.settingUpPage = fetchWorkPackages // put promise in scope for cg-busy
.then(setupPage)
.then(function(json) {
return setupPage(json, !!queryParams);
})
.then(function() {
fetchAvailableColumns();
fetchProjectTypesAndQueries();
@ -109,8 +111,8 @@ module.exports = function($scope, $rootScope, $state, $location, latestTab,
}
}
function setupPage(json) {
initQuery(json.meta);
function setupPage(json, queryParamsPresent) {
initQuery(json.meta, queryParamsPresent);
setupWorkPackagesTable(json);
if (json.work_packages.length) {
@ -118,7 +120,7 @@ module.exports = function($scope, $rootScope, $state, $location, latestTab,
}
}
function initQuery(metaData) {
function initQuery(metaData, queryParamsPresent) {
var queryData = metaData.query,
columnData = metaData.columns;
@ -132,6 +134,9 @@ module.exports = function($scope, $rootScope, $state, $location, latestTab,
} else {
// Set up fresh query from retrieved query meta data
$scope.query = QueryService.initQuery($state.params.query_id, queryData, columnData, metaData.export_formats, afterQuerySetupCallback);
if (queryParamsPresent) {
$scope.query.dirty = true;
}
}
$scope.maintainBackUrl();

@ -75,6 +75,7 @@ module.exports = function(
PaginationService.resetPage();
scope.$emit('queryStateChange');
scope.$emit('workPackagesRefreshRequired');
scope.query.dirty = true;
}
}
}, true);

Loading…
Cancel
Save