Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

III-6019 - As a user I can save a new query on an existing saved search [angular] #772

Merged
merged 13 commits into from
Mar 11, 2024
168 changes: 150 additions & 18 deletions dist/udb3-angular.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions dist/udb3-angular.min.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions src/core/translations/dutch-translations.constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,15 @@ angular.module('udb.core')
viewResults: 'Resultaten bekijken',
yourSearch: 'Jouw zoekopdracht',
save: 'Bewaren',
modal: {
mainTitle: 'Zoekopdracht opslaan',
newTab: 'Nieuwe zoekopdracht',
existingTab: 'Bestaande zoekopdracht',
giveName: 'Geef je zoekopdracht een naam',
selectSavedSearch: 'Kies een bewaarde zoekopdracht',
save: 'Bewaren',
cancel: 'Annuleren'
}
},
manage: 'Beheren',
oneResult: '1 resultaat',
Expand Down
9 changes: 9 additions & 0 deletions src/core/translations/french-translations.constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,15 @@ angular.module('udb.core')
viewResults: 'Consulter résultats',
yourSearch: 'Votre recherche',
save: 'Conserver',
modal: {
mainTitle: 'Enregistrer la recherche',
newTab: 'Nouvelle recherche',
existingTab: 'Recherche existante',
giveName: 'Donnez un nom à votre recherche',
selectSavedSearch: 'Choisissez une recherche existante',
save: 'Enregistrer',
cancel: 'Annuler'
}
},
manage: 'Gérer',
oneResult: '1 résultat',
Expand Down
9 changes: 9 additions & 0 deletions src/core/translations/german-translations.constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,15 @@ angular.module('udb.core').constant('udbGermanTranslations', {
'viewResults': 'Ergebnisse ansehen',
'yourSearch': 'Ihre Suchanfrage',
'save': 'Speichern',
'modal': {
'mainTitle': 'Suche speichern',
'newTab': 'Neue Suche',
'existingTab': 'Vorhandene Suche',
'giveName': 'Gib deiner Suche einen Namen',
'selectSavedSearch': 'Wähle eine vorhandene Suche',
'save': 'Speichern',
'cancel': 'Abbrechen'
}
},
'manage': 'Verwalten',
'oneResult': '1 Ergebnis',
Expand Down
6 changes: 6 additions & 0 deletions src/core/udb-api.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ function UdbApi(
.then(returnUnwrappedData);
};

this.editSavedSearch = function (searchId, name, query) {
return $http
.put(appConfig.baseUrl + 'saved-searches/v3/' + searchId, {name: name, query: query}, defaultApiConfig)
.then(returnUnwrappedData);
};

/**
* @param {string} queryString - The query used to find offers.
* @param {number} [start] - From which offset the result set should start.
Expand Down
57 changes: 53 additions & 4 deletions src/saved-searches/components/save-search-modal.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,72 @@ angular
.controller('SaveSearchModalController', SaveSearchModalController);

/* @ngInject */
function SaveSearchModalController($scope, $uibModalInstance) {
function SaveSearchModalController($scope, udbApi, $q, $uibModalInstance, $translate) {

var ok = function () {
var ok = function (type) {
var name = $scope.queryName;
var id = $scope.queryId;
$scope.wasSubmitted = true;

if (name) {
$uibModalInstance.close(name);
if (type === 'existing') {
$uibModalInstance.close({id: id, name: name, type: type});
}

if (type === 'new' && name) {
$uibModalInstance.close({name: name, type: type});
}

};

var cancel = function () {
$uibModalInstance.dismiss('cancel');
};

var isTabActive = function (tabId) {
return tabId === $scope.activeTabId;
};

var getSavedSearches = function () {
return udbApi.getSavedSearches().then(function (data) {
var withTranslation = data.map(function (savedSearch) {
var key = 'search.savedSearches.items.' + savedSearch.name.toString();
var translated = $translate.instant(key);
if (translated !== key) {
savedSearch.name = translated;
}
return savedSearch;
});
return $q.resolve(withTranslation);
});
};

var makeTabActive = function (tabId) {
$scope.activeTabId = tabId;
if (tabId === 'existing') {
getSavedSearches().then(function (savedSearches) {
$scope.savedSearches = savedSearches;
});
}
};

var setQueryName = function() {
var selectedSavedSearch = $scope.savedSearches.find(function(savedSearch) {
return savedSearch.id === $scope.queryId;
});

if (selectedSavedSearch) {
$scope.queryName = selectedSavedSearch.name;
}
};

$scope.savedSearches = [];
$scope.cancel = cancel;
$scope.ok = ok;
$scope.isTabActive = isTabActive;
$scope.makeTabActive = makeTabActive;
$scope.setQueryName = setQueryName;
$scope.queryName = '';
$scope.queryId = '';
$scope.activeTabId = 'new';
$scope.wasSubmitted = false;
}
Loading
Loading