[27328] Fix invalid menu / form items shown when modifying queries

https://community.openproject.com/wp/27328
pull/6285/head
Oliver Günther 7 years ago
parent 057a288a5f
commit f78fc44a8b
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 2
      frontend/app/components/modals/rename-query-modal/rename-query.modal.ts
  2. 16
      frontend/app/components/modals/share-modal/query-sharing-form.component.ts
  3. 4
      frontend/app/components/op-context-menu/handlers/op-settings-dropdown-menu.directive.ts
  4. 1
      frontend/app/components/wp-query-menu/wp-query-menu.service.ts

@ -90,6 +90,6 @@ export class RenameQueryModal extends OpModalComponent implements OnInit {
.then(() => {
this.closeMe($event);
})
.catch((error) => this.wpNotificationsService.handleRawError(error));
.catch((error) => this.wpNotificationsService.handleErrorResponse(error));
};
}

@ -14,9 +14,7 @@ export interface QuerySharingChange {
selector: 'query-sharing-form',
template: require('!!raw-loader!./query-sharing-form.html')
})
export class QuerySharingForm implements OnInit {
public canPublish:boolean = false;
export class QuerySharingForm {
@Input() public isSave:boolean;
@Input() public isStarred:boolean;
@Input() public isPublic:boolean;
@ -32,17 +30,19 @@ export class QuerySharingForm implements OnInit {
@Inject(I18nToken) readonly I18n:op.I18n) {
}
ngOnInit() {
const form = this.states.query.form.value!;
this.canPublish = form.schema.public.writable;
}
public get canStar() {
return this.isSave ||
this.authorisationService.can('query', 'star') ||
this.authorisationService.can('query', 'unstar');
}
public get canPublish() {
const form = this.states.query.form.value!;
return this.authorisationService.can('query', 'saveImmediately')
&& form.schema.public.writable;
}
public updateStarred(val:boolean) {
this.isStarred = val;
this.changed();

@ -214,7 +214,7 @@ export class OpSettingsMenuDirective extends OpContextMenuTrigger implements OnD
},
{
// Settings modal
disabled: !this.query.id || this.authorisationService.cannot('query', 'update'),
disabled: !this.query.id || this.authorisationService.cannot('query', 'updateImmediately'),
linkText: this.I18n.t('js.toolbar.settings.page_settings'),
icon: 'icon-settings',
onClick: ($event:JQueryEventObject) => {
@ -231,7 +231,7 @@ export class OpSettingsMenuDirective extends OpContextMenuTrigger implements OnD
},
{
// Settings modal
disabled: !this.query.results.customFields,
hidden: !this.query.results.customFields,
href: this.query.results.customFields && this.query.results.customFields.href,
linkText: this.query.results.customFields && this.query.results.customFields.name,
icon: 'icon-custom-fields',

@ -108,6 +108,7 @@ export class QueryMenuService {
private removeItem(queryId:string) {
const item = this.findItem(queryId);
item.remove();
this.setSelectedState();
}

Loading…
Cancel
Save