|
|
|
@ -36,7 +36,7 @@ import { CurrentUserService } from 'core-app/core/current-user/current-user.serv |
|
|
|
|
import { IOpSidemenuItem } from 'core-app/shared/components/sidemenu/sidemenu.component'; |
|
|
|
|
|
|
|
|
|
@Injectable() |
|
|
|
|
export class WorkPackageStaticQueriesService { |
|
|
|
|
export class StaticQueriesService { |
|
|
|
|
constructor(private readonly I18n:I18nService, |
|
|
|
|
private readonly $state:StateService, |
|
|
|
|
private readonly CurrentProject:CurrentProjectService, |
|
|
|
@ -60,32 +60,53 @@ export class WorkPackageStaticQueriesService { |
|
|
|
|
summary: this.I18n.t('js.work_packages.default_queries.summary'), |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
public get all():IOpSidemenuItem[] { |
|
|
|
|
public getStaticName(query:QueryResource):string { |
|
|
|
|
if (this.$state.params.query_props) { |
|
|
|
|
const queryProps = JSON.parse(this.$state.params.query_props) as { pa:unknown, pp:unknown }&unknown; |
|
|
|
|
delete queryProps.pp; |
|
|
|
|
delete queryProps.pa; |
|
|
|
|
const queryPropsString = JSON.stringify(queryProps); |
|
|
|
|
|
|
|
|
|
// TODO: Get module route from query
|
|
|
|
|
const matched = this.getStaticQueries('work-packages').find((item) => { |
|
|
|
|
const uiParams = item.uiParams as { query_id:string, query_props:string }; |
|
|
|
|
return uiParams && uiParams.query_props === queryPropsString; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (matched) { |
|
|
|
|
return matched.title; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Try to detect the all open filter
|
|
|
|
|
if (query.filters.length === 1 // Only one filter
|
|
|
|
|
&& query.filters[0].id === 'status' // that is status
|
|
|
|
|
&& query.filters[0].operator.id === 'o') { // and is open
|
|
|
|
|
return this.text.all_open; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Otherwise, fall back to work packages
|
|
|
|
|
return this.text.work_packages; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public getStaticQueries(module:string):IOpSidemenuItem[] { |
|
|
|
|
let items:IOpSidemenuItem[] = [ |
|
|
|
|
{ |
|
|
|
|
title: this.text.all_open, |
|
|
|
|
uiSref: 'work-packages', |
|
|
|
|
uiSref: module, |
|
|
|
|
uiParams: { query_id: '', query_props: '' }, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: this.text.latest_activity, |
|
|
|
|
uiSref: 'work-packages', |
|
|
|
|
uiSref: module, |
|
|
|
|
uiParams: { |
|
|
|
|
query_id: '', |
|
|
|
|
query_props: '{"c":["id","subject","type","status","assignee","updatedAt"],"hi":false,"g":"","t":"updatedAt:desc","f":[{"n":"status","o":"o","v":[]}]}', |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: this.text.gantt, |
|
|
|
|
uiSref: 'work-packages', |
|
|
|
|
uiParams: { |
|
|
|
|
query_id: '', |
|
|
|
|
query_props: '{"c":["id","type","subject","status","startDate","dueDate"],"tv":true,"tzl":"auto","tll":"{\\"left\\":\\"startDate\\",\\"right\\":\\"dueDate\\",\\"farRight\\":\\"subject\\"}","hi":true,"g":"","t":"startDate:asc","f":[{"n":"status","o":"o","v":[]}]}', |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: this.text.recently_created, |
|
|
|
|
uiSref: 'work-packages', |
|
|
|
|
uiSref: module, |
|
|
|
|
uiParams: { |
|
|
|
|
query_id: '', |
|
|
|
|
query_props: '{"c":["id","subject","type","status","assignee","createdAt"],"hi":false,"g":"","t":"createdAt:desc","f":[{"n":"status","o":"o","v":[]}]}', |
|
|
|
@ -93,12 +114,23 @@ export class WorkPackageStaticQueriesService { |
|
|
|
|
}, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
const projectIdentifier = this.CurrentProject.identifier; |
|
|
|
|
if (projectIdentifier) { |
|
|
|
|
if (module === 'work-packages') { |
|
|
|
|
items.push({ |
|
|
|
|
title: this.text.summary, |
|
|
|
|
href: `${this.PathHelper.projectWorkPackagesPath(projectIdentifier)}/report`, |
|
|
|
|
title: this.text.gantt, |
|
|
|
|
uiSref: module, |
|
|
|
|
uiParams: { |
|
|
|
|
query_id: '', |
|
|
|
|
query_props: '{"c":["id","type","subject","status","startDate","dueDate"],"tv":true,"tzl":"auto","tll":"{\\"left\\":\\"startDate\\",\\"right\\":\\"dueDate\\",\\"farRight\\":\\"subject\\"}","hi":true,"g":"","t":"startDate:asc","f":[{"n":"status","o":"o","v":[]}]}', |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const projectIdentifier = this.CurrentProject.identifier; |
|
|
|
|
if (projectIdentifier) { |
|
|
|
|
items.push({ |
|
|
|
|
title: this.text.summary, |
|
|
|
|
href: `${this.PathHelper.projectWorkPackagesPath(projectIdentifier)}/report`, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (this.CurrentUser.isLoggedIn) { |
|
|
|
@ -106,7 +138,7 @@ export class WorkPackageStaticQueriesService { |
|
|
|
|
...items, |
|
|
|
|
{ |
|
|
|
|
title: this.text.created_by_me, |
|
|
|
|
uiSref: 'work-packages', |
|
|
|
|
uiSref: module, |
|
|
|
|
uiParams: { |
|
|
|
|
query_id: '', |
|
|
|
|
query_props: '{"c":["id","subject","type","status","assignee","updatedAt"],"hi":false,"g":"","t":"updatedAt:desc,id:asc","f":[{"n":"status","o":"o","v":[]},{"n":"author","o":"=","v":["me"]}]}', |
|
|
|
@ -114,7 +146,7 @@ export class WorkPackageStaticQueriesService { |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: this.text.assigned_to_me, |
|
|
|
|
uiSref: 'work-packages', |
|
|
|
|
uiSref: module, |
|
|
|
|
uiParams: { |
|
|
|
|
query_id: '', |
|
|
|
|
query_props: '{"c":["id","subject","type","status","author","updatedAt"],"hi":false,"g":"","t":"updatedAt:desc,id:asc","f":[{"n":"status","o":"o","v":[]},{"n":"assigneeOrGroup","o":"=","v":["me"]}]}', |
|
|
|
@ -125,32 +157,4 @@ export class WorkPackageStaticQueriesService { |
|
|
|
|
|
|
|
|
|
return items; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public getStaticName(query:QueryResource):string { |
|
|
|
|
if (this.$state.params.query_props) { |
|
|
|
|
const queryProps = JSON.parse(this.$state.params.query_props); |
|
|
|
|
delete queryProps.pp; |
|
|
|
|
delete queryProps.pa; |
|
|
|
|
const queryPropsString = JSON.stringify(queryProps); |
|
|
|
|
|
|
|
|
|
const matched = this.all.find((item) => { |
|
|
|
|
const uiParams = item.uiParams as { query_id:string, query_props:string }; |
|
|
|
|
return uiParams && uiParams.query_props === queryPropsString; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (matched) { |
|
|
|
|
return matched.title; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Try to detect the all open filter
|
|
|
|
|
if (query.filters.length === 1 // Only one filter
|
|
|
|
|
&& query.filters[0].id === 'status' // that is status
|
|
|
|
|
&& query.filters[0].operator.id === 'o') { // and is open
|
|
|
|
|
return this.text.all_open; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Otherwise, fall back to work packages
|
|
|
|
|
return this.text.work_packages; |
|
|
|
|
} |
|
|
|
|
} |