parent
a101a67374
commit
85b2ef6c87
@ -0,0 +1,64 @@ |
||||
// -- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See doc/COPYRIGHT.rdoc for more details.
|
||||
// ++
|
||||
import {MultiInputState} from "reactivestates"; |
||||
import {Injectable} from '@angular/core'; |
||||
import {UserResource} from 'core-app/modules/hal/resources/user-resource'; |
||||
import {StateCacheService} from 'core-components/states/state-cache.service'; |
||||
import {States} from 'core-components/states.service'; |
||||
import {StatusResource} from 'core-app/modules/hal/resources/status-resource'; |
||||
import {StatusDmService} from './../../modules/hal/dm-services/status-dm.service'; |
||||
import {PriorityDmService} from "core-app/modules/hal/dm-services/priority-dm.service"; |
||||
import {HalResource} from "core-app/modules/hal/resources/hal-resource"; |
||||
|
||||
@Injectable() |
||||
export class PriorityCacheService extends StateCacheService<HalResource> { |
||||
|
||||
constructor(readonly states:States, |
||||
readonly priorityDm:PriorityDmService) { |
||||
super(); |
||||
} |
||||
|
||||
public requireAllStatuses() { |
||||
return this.loadAll([]); |
||||
} |
||||
|
||||
protected async load(id:string):Promise<HalResource> { |
||||
return this.priorityDm.load(id); |
||||
} |
||||
|
||||
protected async loadAll(_ids:string[]):Promise<undefined> { |
||||
return this.priorityDm.loadAll().then((results) => { |
||||
results.elements.map(el => this.multiState.get(el.id).putValue(el)); |
||||
return undefined; |
||||
}); |
||||
} |
||||
|
||||
protected get multiState():MultiInputState<HalResource> { |
||||
return this.states.priorities; |
||||
} |
||||
} |
@ -0,0 +1,53 @@ |
||||
//-- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See doc/COPYRIGHT.rdoc for more details.
|
||||
//++
|
||||
|
||||
import {HalResourceService} from 'core-app/modules/hal/services/hal-resource.service'; |
||||
import {CollectionResource} from 'core-app/modules/hal/resources/collection-resource'; |
||||
import {HelpTextResource} from 'core-app/modules/hal/resources/help-text-resource'; |
||||
import {PathHelperService} from 'core-components/common/path-helper/path-helper.service'; |
||||
import {Injectable} from '@angular/core'; |
||||
import {HalResource} from 'app/modules/hal/resources/hal-resource'; |
||||
|
||||
@Injectable() |
||||
export class PriorityDmService { |
||||
constructor(protected halResourceService:HalResourceService, |
||||
protected pathHelper:PathHelperService) { |
||||
} |
||||
|
||||
public async loadAll():Promise<CollectionResource<HalResource>> { |
||||
return this.halResourceService |
||||
.get<CollectionResource<HalResource>>(this.pathHelper.api.v3.priorities.toString()) |
||||
.toPromise(); |
||||
} |
||||
|
||||
public async load(id:string):Promise<HalResource> { |
||||
return this.halResourceService |
||||
.get<HalResource>(this.pathHelper.api.v3.priorities.id(id).toString()) |
||||
.toPromise(); |
||||
} |
||||
} |
Loading…
Reference in new issue