parent
c790aeda29
commit
576554e2d9
@ -1,82 +0,0 @@ |
||||
//-- 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 {wpControllersModule} from '../../../angular-modules'; |
||||
import {WorkPackageTableColumnsService} from '../../wp-fast-table/state/wp-table-columns.service'; |
||||
import {TableState} from 'core-components/wp-table/table-state/table-state'; |
||||
import {WorkPackageCollectionResource} from 'core-app/modules/hal/resources/wp-collection-resource'; |
||||
import {HalLink} from 'core-app/modules/hal/hal-link/hal-link'; |
||||
|
||||
interface ExportLink extends HalLink { |
||||
identifier:string; |
||||
} |
||||
|
||||
class ExportModalController { |
||||
public name:string; |
||||
public closeMe:Function; |
||||
public exportOptions:any; |
||||
|
||||
constructor(exportModal:any, |
||||
private UrlParamsHelper:any, |
||||
private tableState:TableState, |
||||
private wpTableColumns:WorkPackageTableColumnsService) { |
||||
var results = this.tableState.results.value!; |
||||
|
||||
this.name = 'Export'; |
||||
this.closeMe = exportModal.deactivate; |
||||
this.exportOptions = this.buildExportOptions(results); |
||||
} |
||||
|
||||
public $onInit() { |
||||
// Created for interface compliance
|
||||
} |
||||
|
||||
private buildExportOptions(results:WorkPackageCollectionResource) { |
||||
return results.representations.map(format => { |
||||
const link = format.$link as ExportLink; |
||||
|
||||
return { |
||||
identifier: link.identifier, |
||||
label: link.title, |
||||
url: this.addColumnsToHref(format.href!) |
||||
}; |
||||
}); |
||||
} |
||||
|
||||
private addColumnsToHref(href:string) { |
||||
let columns = this.wpTableColumns.getColumns(); |
||||
|
||||
let columnIds = columns.map(function (column) { |
||||
return column.id; |
||||
}); |
||||
|
||||
return href + "&" + this.UrlParamsHelper.buildQueryString({ 'columns[]': columnIds }); |
||||
} |
||||
} |
||||
|
||||
wpControllersModule.controller('ExportModalController', ExportModalController); |
@ -1,24 +0,0 @@ |
||||
<div class="ng-modal-window"> |
||||
<div class="ng-modal-inner"> |
||||
<div class="modal-header"> |
||||
<a> |
||||
<i |
||||
class="icon-close" |
||||
ng-click="$ctrl.closeMe()" |
||||
title="{{ ::I18n.t('js.close_popup_title') }}"> |
||||
</i> |
||||
</a> |
||||
</div> |
||||
|
||||
<h3>{{ ::I18n.t('js.label_export') }}</h3> |
||||
|
||||
<ul class="export-options"> |
||||
<li ng-repeat="option in $ctrl.exportOptions"> |
||||
<a ng-href="{{ ::option.url }}" focus="$first" id="export-{{ ::option.identifier }}"> |
||||
<op-icon icon-classes="icon-export-{{ ::option.identifier }} icon-big"></op-icon> |
||||
<span class="export-label">{{ ::option.label }}</span> |
||||
</a> |
||||
</li> |
||||
</ul> |
||||
</div> |
||||
</div> |
@ -1,40 +0,0 @@ |
||||
//-- 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 {wpControllersModule} from '../../../angular-modules'; |
||||
|
||||
function exportModalService(btfModal:any) { |
||||
return btfModal({ |
||||
controller: 'ExportModalController', |
||||
controllerAs: '$ctrl', |
||||
afterFocusOn: '#work-packages-settings-button', |
||||
templateUrl: '/components/modals/export-modal/export-modal.service.html' |
||||
}); |
||||
} |
||||
|
||||
wpControllersModule.factory('exportModal', exportModalService); |
@ -0,0 +1,27 @@ |
||||
<div class="op-modal--container ng-modal-window"> |
||||
<div class="ng-modal-inner wp-table--configuration-modal loading-indicator--location" |
||||
data-indicator-name="modal" |
||||
tabindex="0"> |
||||
<div class="modal-header"> |
||||
<a> |
||||
<i |
||||
class="icon-close" |
||||
(click)="closeMe($event)" |
||||
[attr.title]="text.closePopup"> |
||||
</i> |
||||
</a> |
||||
</div> |
||||
|
||||
<h3 [textContent]="text.title"></h3> |
||||
|
||||
<ul *ngIf="exportOptions" class="export-options"> |
||||
<li *ngFor="let option of exportOptions"> |
||||
<a [attr.href]="option.url" |
||||
id="export-{{ option.identifier }}"> |
||||
<op-icon icon-classes="icon-export-{{ option.identifier }} icon-big"></op-icon> |
||||
<span class="export-label" [textContent]="option.label"></span> |
||||
</a> |
||||
</li> |
||||
</ul> |
||||
</div> |
||||
</div> |
@ -0,0 +1,77 @@ |
||||
import {Component, ElementRef, Inject, OnInit} from '@angular/core'; |
||||
import {I18nToken, OpModalLocalsToken} from 'core-app/angular4-transition-utils'; |
||||
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 {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"; |
||||
|
||||
interface ExportLink extends HalLink { |
||||
identifier:string; |
||||
} |
||||
|
||||
@Component({ |
||||
template: require('!!raw-loader!./wp-table-export.modal.html') |
||||
}) |
||||
export class WpTableExportModal extends OpModalComponent implements OnInit { |
||||
|
||||
/* Close on escape? */ |
||||
public closeOnEscape = true; |
||||
|
||||
/* Close on outside click */ |
||||
public closeOnOutsideClick = true; |
||||
|
||||
public $element:JQuery; |
||||
public exportOptions:{ identifier:string, label:string, url:string }[]; |
||||
|
||||
public text = { |
||||
title: this.I18n.t('js.label_export'), |
||||
closePopup: this.I18n.t('js.close_popup_title'), |
||||
}; |
||||
|
||||
constructor(@Inject(OpModalLocalsToken) public locals:OpModalLocalsMap, |
||||
@Inject(I18nToken) readonly I18n:op.I18n, |
||||
readonly elementRef:ElementRef, |
||||
readonly UrlParamsHelper:UrlParamsHelperService, |
||||
readonly tableState:TableState, |
||||
readonly wpTableColumns:WorkPackageTableColumnsService) { |
||||
super(locals, elementRef); |
||||
} |
||||
|
||||
ngOnInit() { |
||||
this.$element = jQuery(this.elementRef.nativeElement); |
||||
|
||||
this.tableState.results |
||||
.valuesPromise() |
||||
.then((results) => this.exportOptions = this.buildExportOptions(results!)); |
||||
} |
||||
|
||||
private buildExportOptions(results:WorkPackageCollectionResource) { |
||||
return results.representations.map(format => { |
||||
const link = format.$link as ExportLink; |
||||
|
||||
return { |
||||
identifier: link.identifier, |
||||
label: link.title, |
||||
url: this.addColumnsToHref(format.href!) |
||||
}; |
||||
}); |
||||
} |
||||
|
||||
private addColumnsToHref(href:string) { |
||||
let columns = this.wpTableColumns.getColumns(); |
||||
|
||||
let columnIds = columns.map(function (column) { |
||||
return column.id; |
||||
}); |
||||
|
||||
return href + "&" + this.UrlParamsHelper.buildQueryString({ 'columns[]': columnIds }); |
||||
} |
||||
|
||||
protected get afterFocusOn():JQuery { |
||||
return jQuery('#work-packages-settings-button'); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue