hack having the children table provisioned from the backend

pull/6251/head
Jens Ulferts 7 years ago
parent 3e86dafad2
commit 9e4f5053bc
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 11
      app/models/type/attribute_groups.rb
  2. 15
      frontend/app/components/wp-form-group/wp-query-group.component.ts
  3. 30
      frontend/app/components/wp-form-group/wp-query-group.template.html
  4. 11
      frontend/app/components/wp-query/url-params-helper.ts
  5. 4
      lib/api/v3/work_packages/schema/form_configurations/query_representer.rb

@ -110,7 +110,7 @@ module Type::AttributeGroups
ordered << [groupkey, members.sort] if members.present?
end
ordered << [:children, [Query.new_default]]
ordered << [:children, [default_children_query]]
ordered
end
@ -200,4 +200,13 @@ module Type::AttributeGroups
.reject { |key| custom_field?(key) && !has_custom_field?(key) }
.group_by { |key| default_group_key(key.to_sym) }
end
def default_children_query
query = Query.new_default
query.column_names = %w(id type subject)
query.show_hierarchies = false
query.filters = []
query.add_filter('parent', '=', '1')
query
end
end

@ -69,7 +69,6 @@ export class WorkPackageFormQueryGroupComponent implements OnInit, OnDestroy {
];
constructor(protected wpRelationsHierarchyService:WorkPackageRelationsHierarchyService,
protected wpCacheService:WorkPackageCacheService,
protected PathHelper:PathHelperService,
@Inject(UrlParamsHelperServiceToken) protected queryUrlParamsHelper:UrlParamsHelperService,
@Inject(I18nToken) protected I18n:op.I18n) {
@ -79,7 +78,7 @@ export class WorkPackageFormQueryGroupComponent implements OnInit, OnDestroy {
this.canHaveChildren = !this.workPackage.isMilestone;
this.canModifyHierarchy = !!this.workPackage.changeParent;
this.childrenQueryProps = this.queryUrlParamsHelper.buildV3GetQueryFromQueryResource(this.group.query,
this.childrenQueryProps = this.queryUrlParamsHelper.buildV3GetQueryFromQueryResource(this.contextualizedQuery,
{})
}
@ -90,4 +89,16 @@ export class WorkPackageFormQueryGroupComponent implements OnInit, OnDestroy {
public refreshTable() {
this.childrenEmbeddedTable.refresh();
}
private get contextualizedQuery() {
let duppedQuery = _.clone(this.group.query)
_.each(duppedQuery.filters, (filter) => {
if (filter._links.filter.href.endsWith('parent')) {
filter._links.values[0].href = this.PathHelper.workPackagePath(this.workPackage.id);
}
});
return duppedQuery;
}
}

@ -1,16 +1,16 @@
<wp-embedded-table #childrenEmbeddedTable
[compactTableStyle]="true"
[queryProps]="childrenQueryProps"
[tableActions]="childrenTableActions"
[configuration]="{ actionsColumnEnabled: true,
hierarchyToggleEnabled: false,
inlineCreateEnabled: false,
columnMenuEnabled: false,
contextMenuEnabled: false,
projectContext: false }" >
</wp-embedded-table>
<wp-embedded-table #childrenEmbeddedTable
[compactTableStyle]="true"
[queryProps]="childrenQueryProps"
[tableActions]="childrenTableActions"
[configuration]="{ actionsColumnEnabled: true,
hierarchyToggleEnabled: false,
inlineCreateEnabled: false,
columnMenuEnabled: false,
contextMenuEnabled: false,
projectContext: false }" >
</wp-embedded-table>
<wp-relation-add-child
[workPackage]="workPackage"
(onAdded)="refreshTable()"
*ngIf="canModifyHierarchy && canHaveChildren"></wp-relation-add-child>
<wp-relation-add-child
[workPackage]="workPackage"
(onAdded)="refreshTable()"
*ngIf="canModifyHierarchy && canHaveChildren"></wp-relation-add-child>

@ -265,9 +265,12 @@ export class UrlParamsHelperService {
}
private buildV3GetValuesFromFilter(filter:any) {
let values = filter.values ? filter.values : filter._links.values;
if (filter.values) {
return _.map(filter.values, (v) => this.queryFilterValueToParam(v));
} else {
return _.map(filter._links.values, (v:any) => this.idFromHref(v.href));
}
return _.map(values, (v) => this.queryFilterValueToParam(v));
}
private buildV3GetSortByFromQuery(query:QueryResource) {
@ -288,7 +291,9 @@ export class UrlParamsHelperService {
}
private idFromHref(href:string) {
return href.substring(href.lastIndexOf('/') + 1, href.length);
let id = href.substring(href.lastIndexOf('/') + 1, href.length);
return decodeURIComponent(id);
}
}

@ -46,6 +46,10 @@ module API
end,
getter: ->(*) do
next unless embed_links
# For some reason, the context (query) of the filters
# are lost. We therefore set it anew:
query.set_context
::API::V3::Queries::QueryRepresenter.new(query, current_user: current_user)
end

Loading…
Cancel
Save