mirror of https://github.com/abpframework/abp.git
19 changed files with 135 additions and 40 deletions
@ -0,0 +1,30 @@ |
|||
(function () { |
|||
|
|||
const stateKey = 'authentication-state-id'; |
|||
|
|||
window.addEventListener('load', function () { |
|||
if (!abp || !abp.currentUser) { |
|||
return; |
|||
} |
|||
|
|||
if (!abp.currentUser.isAuthenticated) { |
|||
localStorage.removeItem(stateKey); |
|||
} else { |
|||
localStorage.setItem(stateKey, abp.currentUser.id); |
|||
} |
|||
|
|||
window.addEventListener('storage', function (event) { |
|||
|
|||
if (event.key !== stateKey || event.oldValue === event.newValue) { |
|||
return; |
|||
} |
|||
|
|||
if (event.oldValue || !event.newValue) { |
|||
window.location.reload(); |
|||
} else { |
|||
location.assign('/') |
|||
} |
|||
}); |
|||
}); |
|||
|
|||
}()); |
|||
@ -0,0 +1,5 @@ |
|||
export interface SortableItem { |
|||
id?: string | number; |
|||
name?: string; |
|||
order?: number; |
|||
} |
|||
@ -1,27 +1,33 @@ |
|||
import { InjectionToken, inject } from '@angular/core'; |
|||
import { SortableItem } from '../models'; |
|||
import { LocalizationService } from '../services'; |
|||
|
|||
export const SORT_COMPARE_FUNC = new InjectionToken< 0 | 1 | -1 >('SORT_COMPARE_FUNC'); |
|||
export const SORT_COMPARE_FUNC = new InjectionToken<(a: SortableItem, b: SortableItem) => number>( |
|||
'SORT_COMPARE_FUNC', |
|||
); |
|||
|
|||
export function compareFuncFactory() { |
|||
const localizationService = inject(LocalizationService) |
|||
const fn = (a,b) => { |
|||
const localizationService = inject(LocalizationService); |
|||
const fn = (a: SortableItem, b: SortableItem) => { |
|||
const aName = localizationService.instant(a.name); |
|||
const bName = localizationService.instant(b.name); |
|||
const aNumber = a.order; |
|||
const bNumber = b.order; |
|||
|
|||
|
|||
if (!Number.isInteger(aNumber)) return 1; |
|||
if (!Number.isInteger(bNumber)) return -1; |
|||
|
|||
if (aNumber > bNumber) return 1 |
|||
if (aNumber < bNumber) return -1 |
|||
|
|||
if ( aName > bName ) return 1; |
|||
if ( aName < bName ) return -1; |
|||
|
|||
return 0 |
|||
} |
|||
|
|||
return fn |
|||
} |
|||
|
|||
if (aNumber > bNumber) return 1; |
|||
if (aNumber < bNumber) return -1; |
|||
|
|||
if (aName > bName) return 1; |
|||
if (aName < bName) return -1; |
|||
|
|||
if (a.id > b.id) return 1; |
|||
if (a.id < b.id) return -1; |
|||
|
|||
return 0; |
|||
}; |
|||
|
|||
return fn; |
|||
} |
|||
|
|||
Loading…
Reference in new issue