Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open isolated work package query spaces for the table #7042

Merged
merged 17 commits into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/assets/javascripts/onboarding/onboarding_tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
function workPackageTour() {
initializeTour('wpFinished');

waitForElement('.work-package--results-tbody', '.work-packages-split-view--tabletimeline-side', function() {
waitForElement('.work-package--results-tbody', '#content', function() {
startTour(wpOnboardingTourSteps);
});
}
Expand Down
4 changes: 3 additions & 1 deletion app/services/update_type_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
class UpdateTypeService < BaseTypeService
def call(params)
# forbid renaming if it is a standard type
params[:type].delete :name if type.is_standard?
if params[:type] && type.is_standard?
params[:type].delete :name
end

super(params, {})
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/search/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ See docs/COPYRIGHT.rdoc for more details.
<global-search-tabs></global-search-tabs>

<% if params[:work_packages].present? %>
<global-search-work-packages></global-search-work-packages>
<global-search-work-packages-entry></global-search-work-packages-entry>
wielinde marked this conversation as resolved.
Show resolved Hide resolved
<% else %>
<h3><%= l(:label_result_plural) %> (<%= @results_by_type&.values&.sum || '0' %>)</h3>
<% if @results %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class AttributeHelpTextController {

public handleClick() {
this.load().then((resource:any) => {
let modal = this.opModal.show(this.attributeHelpTextsModal, { helpText: resource });
let modal = this.opModal.show(this.attributeHelpTextsModal, 'global', { helpText: resource });
modal.openingEvent.subscribe((modal:any) => {
setTimeout(() => {
//HACK: need to trigger an angular digest in order to have the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class RequestForConfirmationController {
}

public openConfirmationDialog() {
const confirmModal = this.opModalService.show(this.passwordConfirmationModal);
const confirmModal = this.opModalService.show(this.passwordConfirmationModal, 'global');
confirmModal.openingEvent.subscribe((modal:any) => {
setTimeout(() => {
//HACK: need to trigger an angular digest in order to have the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<button class="button -small advanced-filters--toggle"
(click)="wpFiltersService.toggleVisibility()"
[hidden]="wpFiltersService.visible"
[hidden]="visible"
*ngIf="showFilterButton">
<i class="button--icon icon-filter"></i>
<span class="button--text" [textContent]="filterButtonText"></span>
</button>

<div class="work-packages--filters-optional-container" [hidden]="!wpFiltersService.visible">
<div class="work-packages--filters-optional-container" [hidden]="!visible">
<div id="query_form_content" class="hide-when-print">
<query-filters *ngIf="!!filters"
[filters]="filters"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class WorkPackageFilterContainerComponent implements OnDestroy {
@Input('filterButtonText') filterButtonText:string = I18n.t('js.button_filter');
@Output() public filtersChanged = new DebouncedEventEmitter<WorkPackageTableFilters>(componentDestroyed(this));

public visible = false;
public filters = this.wpTableFilters.currentState;

constructor(readonly wpTableFilters:WorkPackageTableFiltersService,
Expand All @@ -51,6 +52,12 @@ export class WorkPackageFilterContainerComponent implements OnDestroy {
.subscribe(() => {
this.filters = this.wpTableFilters.currentState;
});

this.wpFiltersService
.observeUntil(componentDestroyed(this))
.subscribe((visible) => {
this.visible = visible;
});
}

ngOnDestroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ import {I18nService} from "app/modules/common/i18n/i18n.service";
import {WorkPackageTableFiltersService} from "app/components/wp-fast-table/state/wp-table-filters.service";
import {QueryFilterResource} from "app/modules/hal/resources/query-filter-resource";
import {componentDestroyed, untilComponentDestroyed} from "ng2-rx-componentdestroyed";
import {TableState} from "app/components/wp-table/table-state/table-state";
import {WorkPackageCacheService} from "app/components/work-packages/work-package-cache.service";
import {Subject} from "rxjs";
import {debounceTime, distinctUntilChanged} from "rxjs/operators";
import {DebouncedEventEmitter} from "core-components/angular/debounced-event-emitter";
import {WorkPackageTableFilters} from "core-components/wp-fast-table/wp-table-filters";
import {IsolatedQuerySpace} from "core-app/modules/work_packages/query-space/isolated-query-space";

@Component({
selector: 'wp-filter-by-text-input',
Expand All @@ -59,7 +59,7 @@ export class WorkPackageFilterByTextInputComponent implements OnInit, OnDestroy
private availableSearchFilter:QueryFilterResource;

constructor(readonly I18n:I18nService,
readonly tableState:TableState,
readonly querySpace:IsolatedQuerySpace,
readonly wpTableFilters:WorkPackageTableFiltersService,
readonly wpCacheService:WorkPackageCacheService) {
this.searchTermChanged
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,27 @@
// ++

import {Injectable} from "@angular/core";
import {input} from "reactivestates";
import {Observable} from "rxjs";
import {takeUntil} from "rxjs/operators";

@Injectable()
export class WorkPackageFiltersService {
public visible:boolean = false;
private readonly state = input<boolean>(false);

public get visible() {
return this.state.getValueOr(false);
}

public set visible(val:boolean) {
this.state.putValue(val);
}

public observeUntil(unsubscribe:Observable<any>) {
return this.state.values$().pipe(takeUntil(unsubscribe));
}

public toggleVisibility() {
this.visible = !this.visible;
this.state.doModify((current) => !current);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,21 @@

import {ConfirmDialogModal, ConfirmDialogOptions} from "core-components/modals/confirm-dialog/confirm-dialog.modal";
import {OpModalService} from "core-components/op-modals/op-modal.service";
import {Injectable} from "@angular/core";
import {Injectable, Injector} from "@angular/core";

@Injectable()
export class ConfirmDialogService {

constructor(readonly opModalService:OpModalService) {
constructor(readonly opModalService:OpModalService,
readonly injector:Injector) {
}

/**
* Confirm an action with an ng dialog with the given options
*/
public confirm(options:ConfirmDialogOptions):Promise<void> {
return new Promise<void>((resolve, reject) => {
const confirmModal = this.opModalService.show(ConfirmDialogModal, { options: options });
const confirmModal = this.opModalService.show(ConfirmDialogModal, this.injector, { options: options });
confirmModal.closingEvent.subscribe((modal:ConfirmDialogModal) => {
if (modal.confirmed) {
resolve();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// ++

import {OpModalService} from "core-components/op-modals/op-modal.service";
import {Injectable} from "@angular/core";
import {Injectable, Injector} from "@angular/core";
import {WpButtonMacroModal} from "core-components/modals/editor/macro-wp-button-modal/wp-button-macro.modal";
import {WikiIncludePageMacroModal} from "core-components/modals/editor/macro-wiki-include-page-modal/wiki-include-page-macro.modal";
import {CodeBlockMacroModal} from "core-components/modals/editor/macro-code-block-modal/code-block-macro.modal";
Expand All @@ -37,7 +37,8 @@ import {ChildPagesMacroModal} from "core-components/modals/editor/macro-child-pa
@Injectable()
export class EditorMacrosService {

constructor(readonly opModalService:OpModalService) {
constructor(readonly opModalService:OpModalService,
readonly injector:Injector) {
}

/**
Expand All @@ -46,7 +47,7 @@ export class EditorMacrosService {
*/
public configureWorkPackageButton(typeName?:string, classes?:string):Promise<{ type:string, classes:string }> {
return new Promise<{ type:string, classes:string }>((resolve, reject) => {
const modal = this.opModalService.show(WpButtonMacroModal, { type: typeName, classes: classes });
const modal = this.opModalService.show(WpButtonMacroModal, this.injector, { type: typeName, classes: classes });
modal.closingEvent.subscribe((modal:WpButtonMacroModal) => {
if (modal.changed) {
resolve({type: modal.type, classes: modal.classes});
Expand All @@ -62,7 +63,7 @@ export class EditorMacrosService {
public configureWikiPageInclude(page:string):Promise<string> {
return new Promise<string>((resolve, _) => {
const pageValue = page || '';
const modal = this.opModalService.show(WikiIncludePageMacroModal, { page: pageValue });
const modal = this.opModalService.show(WikiIncludePageMacroModal, this.injector, { page: pageValue });
modal.closingEvent.subscribe((modal:WikiIncludePageMacroModal) => {
if (modal.changed) {
resolve(modal.page);
Expand All @@ -77,7 +78,7 @@ export class EditorMacrosService {
*/
public editCodeBlock(content:string, languageClass:string):Promise<{ content:string, languageClass:string }> {
return new Promise<{ content:string, languageClass:string }>((resolve, _) => {
const modal = this.opModalService.show(CodeBlockMacroModal, { content: content, languageClass: languageClass });
const modal = this.opModalService.show(CodeBlockMacroModal, this.injector, { content: content, languageClass: languageClass });
modal.closingEvent.subscribe((modal:CodeBlockMacroModal) => {
if (modal.changed) {
resolve({languageClass: modal.languageClass, content: modal.content});
Expand All @@ -92,7 +93,7 @@ export class EditorMacrosService {
*/
public configureChildPages(page:string, includeParent:string):Promise<object> {
return new Promise<object>((resolve, _) => {
const modal = this.opModalService.show(ChildPagesMacroModal, { page: page, includeParent: includeParent });
const modal = this.opModalService.show(ChildPagesMacroModal, this.injector,{ page: page, includeParent: includeParent });
modal.closingEvent.subscribe((modal:ChildPagesMacroModal) => {
if (modal.changed) {
resolve({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ import {OpModalLocalsToken} from "core-components/op-modals/op-modal.service";
import {AfterViewInit, ChangeDetectorRef, Component, ElementRef, Inject, ViewChild} from "@angular/core";
import {OpModalLocalsMap} from "core-components/op-modals/op-modal.types";
import {I18nService} from "core-app/modules/common/i18n/i18n.service";
import {WorkPackageCreateService} from "core-components/wp-new/wp-create.service";
import {IWorkPackageCreateServiceToken} from "core-components/wp-new/wp-create.service.interface";
import {TypeResource} from "core-app/modules/hal/resources/type-resource";
import {CurrentProjectService} from "core-components/projects/current-project.service";
import {WorkPackageDmService} from "core-app/modules/hal/dm-services/work-package-dm.service";

@Component({
templateUrl: './wp-button-macro.modal.html'
Expand Down Expand Up @@ -68,8 +67,8 @@ export class WpButtonMacroModal extends OpModalComponent implements AfterViewIni

constructor(readonly elementRef:ElementRef,
@Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,
@Inject(IWorkPackageCreateServiceToken) protected wpCreate:WorkPackageCreateService,
protected currentProject:CurrentProjectService,
readonly currentProject:CurrentProjectService,
readonly workPackageDmService:WorkPackageDmService,
readonly cdRef:ChangeDetectorRef,
readonly I18n:I18nService) {

Expand All @@ -78,7 +77,8 @@ export class WpButtonMacroModal extends OpModalComponent implements AfterViewIni
this.classes = this.locals.classes;
this.buttonStyle = this.classes === 'button';

this.wpCreate.getEmptyForm(this.currentProject.identifier)
this.workPackageDmService
.emptyCreateForm({}, this.currentProject.identifier)
.then((form:any) => {
this.availableTypes = form.schema.type.allowedValues;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {ChangeDetectorRef, Component, ElementRef, Inject, OnInit} from '@angular
import {OpModalLocalsMap} from 'core-components/op-modals/op-modal.types';
import {WorkPackageTableColumnsService} from 'core-components/wp-fast-table/state/wp-table-columns.service';
import {OpModalComponent} from 'core-components/op-modals/op-modal.component';
import {TableState} from 'core-components/wp-table/table-state/table-state';
import {IsolatedQuerySpace} from "core-app/modules/work_packages/query-space/isolated-query-space";
import {UrlParamsHelperService} from "core-components/wp-query/url-params-helper";
import {WorkPackageCollectionResource} from "core-app/modules/hal/resources/wp-collection-resource";
import {HalLink} from "core-app/modules/hal/hal-link/hal-link";
Expand Down Expand Up @@ -36,7 +36,7 @@ export class WpTableExportModal extends OpModalComponent implements OnInit {
readonly I18n:I18nService,
readonly elementRef:ElementRef,
readonly UrlParamsHelper:UrlParamsHelperService,
readonly tableState:TableState,
readonly querySpace:IsolatedQuerySpace,
readonly cdRef:ChangeDetectorRef,
readonly wpTableColumns:WorkPackageTableColumnsService) {
super(locals, cdRef, elementRef);
Expand All @@ -45,7 +45,7 @@ export class WpTableExportModal extends OpModalComponent implements OnInit {
ngOnInit() {
super.ngOnInit();

this.tableState.results
this.querySpace.results
.valuesPromise()
.then((results) => this.exportOptions = this.buildExportOptions(results!));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
// See doc/COPYRIGHT.rdoc for more details.
//++

import {WorkPackagesListService} from '../../wp-list/wp-list.service';
import {States} from '../../states.service';
import {WorkPackageNotificationService} from '../../wp-edit/wp-notification.service';
import {QueryResource} from 'core-app/modules/hal/resources/query-resource';
Expand All @@ -37,7 +36,8 @@ import {OpModalLocalsToken} from "core-components/op-modals/op-modal.service";
import {OpModalLocalsMap} from "core-components/op-modals/op-modal.types";
import {QuerySharingChange} from "core-components/modals/share-modal/query-sharing-form.component";
import {I18nService} from "core-app/modules/common/i18n/i18n.service";
import {TableState} from "core-components/wp-table/table-state/table-state";
import {IsolatedQuerySpace} from "core-app/modules/work_packages/query-space/isolated-query-space";
import {WorkPackagesListService} from "core-components/wp-list/wp-list.service";

@Component({
templateUrl: './save-query.modal.html'
Expand Down Expand Up @@ -65,7 +65,7 @@ export class SaveQueryModal extends OpModalComponent {
@Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,
readonly I18n:I18nService,
readonly states:States,
readonly tableState:TableState,
readonly querySpace:IsolatedQuerySpace,
readonly wpListService:WorkPackagesListService,
readonly wpNotificationsService:WorkPackageNotificationService,
readonly cdRef:ChangeDetectorRef,
Expand All @@ -92,7 +92,7 @@ export class SaveQueryModal extends OpModalComponent {
}

this.isBusy = true;
const query = this.tableState.query.value!;
const query = this.querySpace.query.value!;
query.public = this.isPublic;

this.wpListService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {States} from '../../states.service';
import {AuthorisationService} from 'core-app/modules/common/model-auth/model-auth.service';
import {Component, EventEmitter, Input, Output} from "@angular/core";
import {I18nService} from "core-app/modules/common/i18n/i18n.service";
import {TableState} from "core-components/wp-table/table-state/table-state";
import {IsolatedQuerySpace} from "core-app/modules/work_packages/query-space/isolated-query-space";

export interface QuerySharingChange {
isStarred:boolean;
Expand All @@ -25,7 +25,7 @@ export class QuerySharingForm {
};

constructor(readonly states:States,
readonly tableState:TableState,
readonly querySpace:IsolatedQuerySpace,
readonly authorisationService:AuthorisationService,
readonly I18n:I18nService) {
}
Expand All @@ -37,7 +37,7 @@ export class QuerySharingForm {
}

public get canPublish() {
const form = this.tableState.queryForm.value!;
const form = this.querySpace.queryForm.value!;

return this.authorisationService.can('query', 'updateImmediately')
&& form.schema.public.writable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {OpModalLocalsToken} from "core-components/op-modals/op-modal.service";
import {OpModalLocalsMap} from "core-components/op-modals/op-modal.types";
import {QuerySharingChange} from "core-components/modals/share-modal/query-sharing-form.component";
import {I18nService} from "core-app/modules/common/i18n/i18n.service";
import {TableState} from "core-components/wp-table/table-state/table-state";
import {IsolatedQuerySpace} from "core-app/modules/work_packages/query-space/isolated-query-space";

@Component({
templateUrl: './query-sharing.modal.html'
Expand All @@ -63,7 +63,7 @@ export class QuerySharingModal extends OpModalComponent implements OnInit {
@Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,
readonly I18n:I18nService,
readonly states:States,
readonly tableState:TableState,
readonly querySpace:IsolatedQuerySpace,
readonly cdRef:ChangeDetectorRef,
readonly wpListService:WorkPackagesListService,
readonly wpNotificationsService:WorkPackageNotificationService,
Expand All @@ -74,7 +74,7 @@ export class QuerySharingModal extends OpModalComponent implements OnInit {
ngOnInit() {
super.ngOnInit();

this.query = this.tableState.query.value!;
this.query = this.querySpace.query.value!;

this.isStarred = this.query.starred;
this.isPublic = this.query.public;
Expand Down