Merge pull request #4619 from oliverguenther/fix/23574/save-notification

Show 'Open in full screen' notification only when not in fullscreen
pull/4625/merge
Markus Kahl 8 years ago committed by GitHub
commit 0307ef09a6
  1. 14
      frontend/app/components/work-packages/wp-single-view/wp-single-view.directive.ts
  2. 18
      frontend/app/components/wp-create/wp-create.controller.ts
  3. 3
      frontend/app/components/wp-edit/wp-edit-form.directive.ts
  4. 32
      frontend/app/components/wp-edit/wp-notification.service.ts

@ -33,6 +33,7 @@ import {
WorkPackageResourceInterface
} from '../../api/api-v3/hal-resources/work-package-resource.service';
import {WorkPackageEditFormController} from "../../wp-edit/wp-edit-form.directive";
import {WorkPackageNotificationService} from '../../wp-edit/wp-notification.service';
export class WorkPackageSingleViewController {
public formCtrl: WorkPackageEditFormController;
@ -53,7 +54,7 @@ export class WorkPackageSingleViewController {
protected loadingIndicator,
protected I18n,
protected wpCacheService,
protected NotificationsService,
protected wpNotificationsService:WorkPackageNotificationService,
protected WorkPackagesOverviewService,
protected inplaceEditAll,
protected wpAttachments,
@ -72,17 +73,8 @@ export class WorkPackageSingleViewController {
};
scopedObservable($scope, wpCacheService.loadWorkPackage(wpId)).subscribe(wp => this.init(wp));
$scope.$on('workPackageUpdatedInEditor', () => {
NotificationsService.addSuccess({
message: I18n.t('js.notice_successful_update'),
link: {
target: () => {
loadingIndicator.mainPage = $state.go('work-packages.show.activity', $state.params);
},
text: I18n.t('js.work_packages.message_successful_show_in_fullscreen')
}
});
this.wpNotificationsService.showSave(this.workPackage);
});
}

@ -33,6 +33,7 @@ import {WorkPackageCacheService} from "../work-packages/work-package-cache.servi
import {scopedObservable} from "../../helpers/angular-rx-utils";
import IRootScopeService = angular.IRootScopeService;
import {WorkPackageEditModeStateService} from "../wp-edit/wp-edit-mode-state.service";
import {WorkPackageNotificationService} from '../wp-edit/wp-notification.service';
export class WorkPackageCreateController {
public newWorkPackage:WorkPackageResource|any;
@ -52,7 +53,7 @@ export class WorkPackageCreateController {
protected $rootScope:IRootScopeService,
protected $q:ng.IQService,
protected I18n:op.I18n,
protected NotificationsService,
protected wpNotificationsService:WorkPackageNotificationService,
protected loadingIndicator,
protected wpCreate:WorkPackageCreateService,
protected wpEditModeState:WorkPackageEditModeStateService,
@ -98,20 +99,7 @@ export class WorkPackageCreateController {
this.loadingIndicator.mainPage = this.$state.go(successState, {workPackageId: wp.id})
.then(() => {
this.$rootScope.$emit('workPackagesRefreshInBackground');
this.notifySuccess();
});
}
private notifySuccess() {
this.NotificationsService.addSuccess({
message: this.I18n.t('js.notice_successful_create'),
link: {
target: () => {
this.loadingIndicator.mainPage =
this.$state.go('work-packages.show.activity', this.$state.params);
},
text: this.I18n.t('js.work_packages.message_successful_show_in_fullscreen')
}
this.wpNotificationsService.showSave(wp, true);
});
}
}

@ -118,6 +118,7 @@ export class WorkPackageEditFormController {
}
var deferred = this.$q.defer();
var isInitial = this.workPackage.isNew;
// Reset old error notifcations
this.$rootScope.$emit('notifications.clearAll');
@ -128,7 +129,7 @@ export class WorkPackageEditFormController {
angular.forEach(this.fields, field => field.setErrors([]));
deferred.resolve(this.workPackage);
this.wpNotificationsService.showSave(this.workPackage, this.loadingIndicator);
this.wpNotificationsService.showSave(this.workPackage, isInitial);
this.successHandler({workPackage: this.workPackage, fields: this.fields});
})
.catch((error) => {

@ -27,6 +27,7 @@
// ++
import {openprojectModule} from '../../angular-modules';
import {WorkPackageResourceInterface} from '../api/api-v3/hal-resources/work-package-resource.service';
export class WorkPackageNotificationService {
constructor(protected I18n,
@ -35,18 +36,17 @@ export class WorkPackageNotificationService {
protected loadingIndicator) {
}
public showSave(workPackage) {
var message = 'js.notice_successful_' + (workPackage.inlineCreated ? 'create' : 'update');
this.NotificationsService.addSuccess({
message: this.I18n.t(message),
link: {
target: _ => {
this.loadingIndicator.mainPage =
this.$state.go('work-packages.show.activity', {workPackageId: workPackage.id});
},
text: this.I18n.t('js.work_packages.message_successful_show_in_fullscreen')
public showSave(workPackage: WorkPackageResourceInterface, isCreate:boolean = false) {
var message:any = {
message: this.I18n.t('js.notice_successful_' + (isCreate ? 'create' : 'update')),
};
// Don't show the 'Show in full screen' link if we're there already
if (!this.$state.includes('work-packages.show')) {
message.link = this.showInFullScreenLink(workPackage);
}
});
this.NotificationsService.addSuccess(message);
}
public showError(errorResource, workPackage) {
@ -88,6 +88,16 @@ export class WorkPackageNotificationService {
return true;
}
private showInFullScreenLink(workPackage) {
return {
target: () => {
this.loadingIndicator.mainPage =
this.$state.go('work-packages.show.activity', { workPackageId: workPackage.id });
},
text: this.I18n.t('js.work_packages.message_successful_show_in_fullscreen')
};
}
}
openprojectModule.service('wpNotificationsService', WorkPackageNotificationService);

Loading…
Cancel
Save