Merge branch 'wp-edit-sync' of github.com:romanroe/openproject into wp-edit-sync

pull/4338/head
Alex Dik 9 years ago
commit 7848fedd7b
  1. 2
      frontend/app/components/api/api-v3/hal-resources/work-package-resource.service.ts
  2. 4
      frontend/app/components/routing/wp-details/wp.list.details.html
  3. 10
      frontend/app/components/work-packages/work-package-cache.service.ts
  4. 13
      frontend/app/components/work-packages/wp-subject/wp-subject.directive.html
  5. 60
      frontend/app/components/work-packages/wp-subject/wp-subject.directive.ts

@ -147,7 +147,7 @@ export default class WorkPackageResource extends HalResource {
this.saveResource(payload)
.then(workPackage => {
angular.extend(this, workPackage);
wpCacheService.updateWorkPackageList([this]);
wpCacheService.updateWorkPackage(this);
deferred.resolve(this);
}).catch((error) => {
deferred.reject(error);

@ -26,9 +26,7 @@
<span class="hidden-for-sighted" tabindex="-1" focus ng-bind="focusAnchorLabel">
</span>
<div class="work-packages--details--title">
<wp-field field-name="'subject'"></wp-field>
</div>
<wp-subject></wp-subject>
<div class="work-package-details-tab" ui-view></div>

@ -29,7 +29,6 @@
import {openprojectModule} from "../../angular-modules";
import WorkPackageResource from "../api/api-v3/hal-resources/work-package-resource.service";
import WorkPackage = op.WorkPackage;
export class WorkPackageCacheService {
@ -38,6 +37,15 @@ export class WorkPackageCacheService {
workPackagesSubject = new Rx.ReplaySubject<{[id: number]: WorkPackageResource}>(1);
/*@ngInject*/
constructor(private $rootScope) {
}
updateWorkPackage(wp: WorkPackageResource) {
this.updateWorkPackageList([wp]);
this.$rootScope.$broadcast('workPackageRefreshRequired');
}
updateWorkPackageList(list: WorkPackageResource[]) {
for (const wp of list) {
this.workPackageCache[wp.id] = wp;

@ -0,0 +1,13 @@
<div ng-if="$ctrl.workPackage" wp-edit-form="$ctrl.workPackage">
<div
wp-edit-field="'subject'"
class="work-packages--details--title">
<wp-display-attr
schema="$ctrl.workPackage.schema"
work-package="$ctrl.workPackage"
attribute="'subject'">
</wp-display-attr>
</div>
</div>

@ -0,0 +1,60 @@
// -- 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 {opWorkPackagesModule} from "../../../angular-modules";
import {scopedObservable} from "../../../helpers/angular-rx-utils";
import WorkPackageResource from "../../api/api-v3/hal-resources/work-package-resource.service";
export class WorkPackageSubjectController {
public workPackage: WorkPackageResource;
constructor(protected $scope,
protected $stateParams,
protected wpCacheService) {
scopedObservable($scope, wpCacheService.loadWorkPackage($stateParams.workPackageId))
.subscribe((wp: WorkPackageResource) => {
this.workPackage = wp;
this.workPackage.schema.$load();
});
}
}
function wpSubjectDirective() {
return {
restrict: 'E',
templateUrl: '/components/work-packages/wp-subject/wp-subject.directive.html',
scope: {},
bindToController: true,
controller: WorkPackageSubjectController,
controllerAs: '$ctrl'
};
}
opWorkPackagesModule.directive('wpSubject', wpSubjectDirective);
Loading…
Cancel
Save