Skip to content

Commit 1300a3e

Browse files
committed
correcting js syntax errors
1 parent bf0c6f4 commit 1300a3e

3 files changed

Lines changed: 31 additions & 22 deletions

File tree

kahuna/public/js/components/gr-tab-swap/gr-tab-swap.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface TabSwapProps {
1111
panelVisible: boolean;
1212
}
1313

14-
export const TAB_WITH: string = "with";
14+
export const TAB_WITH = "with";
1515

1616
export const TabControl: React.FC<TabSwapProps> = ({ onSelect, query, showTakenTab, noTakenDateCount, panelVisible }) => {
1717

kahuna/public/js/search/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import panelTemplate from '../components/gr-info-panel/gr-info-panel.html
3030
import collectionsPanelTemplate from
3131
'../components/gr-collections-panel/gr-collections-panel.html';
3232
import {cropUtil} from '../util/crop';
33-
import { HAS_DATE_TAKEN, HASNT_DATE_TAKEN, COLLECTION_SORT_VALUE } from '../components/gr-sort-control/gr-sort-control-config';
33+
import { COLLECTION_SORT_VALUE } from '../components/gr-sort-control/gr-sort-control-config';
3434

3535
export var search = angular.module('kahuna.search', [
3636
'ct.ui.router.extras.dsr',
@@ -326,7 +326,7 @@ search.run(['$rootScope', '$state', function($rootScope, $state) {
326326
$state.go('search.results', null, {reload: true});
327327
}
328328
});
329-
$rootScope.$on('$stateChangeStart', (_, toState, toParams, fromState, fromParams) => {
329+
$rootScope.$on('$stateChangeStart', (_, toState, toParams) => {
330330
if (toState.name === 'search.results') {
331331
//If moving to a collection, sorts images by time added to a collection by default
332332
//allows sorting by newest first if set by user. Need to account for 'With Taken Date' tab impacts on query

kahuna/public/js/search/query.js

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ import {
2424
DefaultSortOption,
2525
CollectionSortOption,
2626
HAS_DATE_TAKEN,
27-
TAKEN_SORT,
28-
SortOptions
27+
TAKEN_SORT
2928
} from "../components/gr-sort-control/gr-sort-control-config";
3029

3130
export var query = angular.module('kahuna.search.query', [
@@ -190,7 +189,7 @@ query.controller('SearchQueryCtrl', [
190189
}
191190

192191
function checkForCollection(query) {
193-
return /~"[a-zA-Z0-9 #-_.://]+"/.test(query)
192+
return /~"[a-zA-Z0-9 #-_.://]+"/.test(query);
194193
};
195194

196195
function storeCollection(query) {
@@ -214,6 +213,29 @@ query.controller('SearchQueryCtrl', [
214213
storage.setJs("priorOrderBy", priorOrderBy);
215214
}
216215

216+
function revisedOrderBy(collectionSearch) {
217+
if (collectionSearch) {
218+
return CollectionSortOption.value;
219+
} else {
220+
return DefaultSortOption.value;
221+
}
222+
}
223+
224+
function priorRevisedOrderBy(collectionSearch, newCollection, oldCollection) {
225+
const priorOrderBy = getPiorOrderBy();
226+
if (collectionSearch && ((oldCollection !== newCollection) || ("" !== priorOrderBy))) {
227+
if (priorOrderBy != "") {
228+
setPriorOrderBy("");
229+
return priorOrderBy;
230+
} else {
231+
setPriorOrderBy(CollectionSortOption.value);
232+
return null;
233+
}
234+
} else {
235+
return null;
236+
}
237+
}
238+
217239
// eslint-disable-next-line complexity
218240
function watchSearchChange(newFilter, sender) {
219241
let showPaid = newFilter.nonFree ? newFilter.nonFree : false;
@@ -223,7 +245,6 @@ query.controller('SearchQueryCtrl', [
223245
storage.setJs("isNonFree", showPaid, true);
224246

225247
// check for taken date sort contradiction
226-
const oldOrderBy = storage.getJs("orderBy");
227248
const curCollectionSearch = ctrl.collectionSearch;
228249
ctrl.collectionSearch = newFilter.query ? checkForCollection(newFilter.query) : false;
229250
const oldCollection = getCollection();
@@ -234,22 +255,10 @@ query.controller('SearchQueryCtrl', [
234255
ctrl.ordering["orderBy"] = $stateParams.orderBy;
235256
}
236257
if ($stateParams.orderBy && $stateParams.orderBy.includes(TAKEN_SORT) && (!newFilter.query || !newFilter.query.includes(HAS_DATE_TAKEN))) {
237-
if (ctrl.collectionSearch) {
238-
ctrl.ordering["orderBy"] = CollectionSortOption.value;
239-
} else {
240-
ctrl.ordering["orderBy"] = DefaultSortOption.value;
241-
}
258+
ctrl.ordering["orderBy"] = revisedOrderBy(ctrl.collectionSearch);
242259
} else {
243-
const priorOrderBy = getPiorOrderBy();
244-
if (ctrl.collectionSearch && ((oldCollection !== newCollection) || ("" !== priorOrderBy))) {
245-
if (priorOrderBy != "") {
246-
ctrl.ordering["orderBy"] = priorOrderBy;
247-
setPriorOrderBy("");
248-
} else {
249-
//console.log("Old collection="+oldCollection + ", New collection=" + newCollection + ", PriorOrderBy=" +priorOrderBy);
250-
setPriorOrderBy(CollectionSortOption.value);
251-
}
252-
}
260+
const prior = priorRevisedOrderBy(ctrl.collectionSearch, newCollection, oldCollection);
261+
ctrl.ordering["orderBy"] = prior ? prior : ctrl.ordering["orderBy"];
253262
}
254263
}
255264
let sortBy = ctrl.ordering["orderBy"] ? ctrl.ordering["orderBy"] : DefaultSortOption.value;

0 commit comments

Comments
 (0)