parent
92ce554e53
commit
73d55f9e43
@ -0,0 +1,8 @@ |
||||
class AddCustomActions < ActiveRecord::Migration[5.0] |
||||
def change |
||||
create_table :custom_actions do |t| |
||||
t.string :name |
||||
t.text :actions |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,12 @@ |
||||
<div class="form--field"> |
||||
<label class="form--label" for="add-section">{{texts.add}}</label> |
||||
<span class="form--field-container"> |
||||
<span class="form--text-field-container -middle"> |
||||
<select id="add-section" [(ngModel)]="turnedActive" (ngModelChange)="show()"> |
||||
<option [ngValue]="null">{{texts.placeholder}}</option> |
||||
<option *ngFor="let n of selectable" [ngValue]="n">{{n.label}}</option> |
||||
</select> |
||||
</span> |
||||
</span> |
||||
</div> |
||||
|
@ -0,0 +1,67 @@ |
||||
// -- 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 {opUiComponentsModule} from '../../../../angular-modules'; |
||||
import {Component, Inject, OnInit} from '@angular/core'; |
||||
import {downgradeComponent} from '@angular/upgrade/static'; |
||||
import {HideSectionDefinition, HideSectionService} from 'core-components/common/hide-section/hide-section.service'; |
||||
import {I18nToken} from 'core-app/angular4-transition-utils'; |
||||
|
||||
@Component({ |
||||
selector: 'add-section-dropdown', |
||||
template: require('!!raw-loader!./add-section-dropdown.component.html') |
||||
}) |
||||
export class AddSectionDropdownComponent implements OnInit { |
||||
selectable:HideSectionDefinition[] = []; |
||||
turnedActive:HideSectionDefinition|null = null; |
||||
texts: { [key:string]: string } = {}; |
||||
|
||||
constructor(protected hideSections:HideSectionService, |
||||
@Inject(I18nToken) protected I18n:op.I18n) { |
||||
this.texts = { |
||||
placeholder: I18n.t('js.placeholders.default'), |
||||
add: I18n.t('js.custom_actions.add') |
||||
}; |
||||
} |
||||
|
||||
ngOnInit() { |
||||
this.selectable = this.hideSections.available; |
||||
} |
||||
|
||||
show() { |
||||
if (this.turnedActive) { |
||||
this.hideSections.show(this.turnedActive); |
||||
setTimeout(() => { this.turnedActive = null } ); |
||||
} |
||||
} |
||||
} |
||||
|
||||
opUiComponentsModule.directive( |
||||
'addSectionDropdown', |
||||
downgradeComponent({component: AddSectionDropdownComponent}) |
||||
); |
@ -0,0 +1,8 @@ |
||||
<accessible-by-keyboard |
||||
iconClasses="icon-close" |
||||
(execute)="hideSection()" |
||||
aria-hidden="false" |
||||
linkTitle="Remove" |
||||
linkAriaLabel="Remove"> |
||||
<op-icon icon-classes="icon-close" icon-title="Remove"></op-icon> |
||||
</accessible-by-keyboard> |
@ -0,0 +1,69 @@ |
||||
// -- 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 {Injectable} from '@angular/core'; |
||||
import {GonRef} from 'core-components/common/gon-ref/gon-ref'; |
||||
|
||||
export interface HideSectionDefinition { |
||||
key: string, |
||||
label: string |
||||
} |
||||
|
||||
@Injectable() |
||||
export class HideSectionService { |
||||
protected availableSections:HideSectionDefinition[] = []; |
||||
protected displayedSections:HideSectionDefinition[] = []; |
||||
|
||||
constructor(protected gonRef:GonRef) { |
||||
this.availableSections = gonRef.get('hideSections').sort((a:HideSectionDefinition, b:HideSectionDefinition) => a.label.localeCompare(b.label)); |
||||
} |
||||
|
||||
isDisplayed(key:string) { |
||||
return _.some(this.displayedSections, (candidate) => candidate.key === key); |
||||
} |
||||
|
||||
hide(key:string) { |
||||
let section = _.remove(this.displayedSections, (candidate) => candidate.key === key); |
||||
this.availableSections.push(_.first(section)); |
||||
this.availableSections.sort((a, b) => a.label.localeCompare(b.label)); |
||||
} |
||||
|
||||
show(section:HideSectionDefinition) { |
||||
_.remove(this.availableSections, (candidate) => candidate === section); |
||||
this.displayedSections.push(section); |
||||
} |
||||
|
||||
get available() { |
||||
return this.availableSections; |
||||
} |
||||
|
||||
hideByName(sectionName:string) { |
||||
let section = _.remove(this.displayedSections, (candidate) => candidate.key === sectionName); |
||||
this.availableSections.push(_.first(section)); |
||||
this.availableSections.sort((a, b) => a.label.localeCompare(b.label)); |
||||
} |
||||
} |
@ -1,5 +0,0 @@ |
||||
<ng-content></ng-content> |
||||
|
||||
<select [(ngModel)]="turnedActive" (ngModelChange)="show($event)"> |
||||
<option *ngFor="let n of selectable" [ngValue]="n">{{n}}</option> |
||||
</select> |
@ -0,0 +1,55 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2017 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-2017 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. |
||||
#++ |
||||
|
||||
require 'support/pages/page' |
||||
|
||||
module Pages |
||||
module Admin |
||||
class NewCustomAction < ::Pages::Page |
||||
def set_name(name) |
||||
fill_in 'Name', with: name |
||||
end |
||||
|
||||
def add_action(name, value) |
||||
within '#custom-actions-form--actions' do |
||||
select name, from: 'Add' |
||||
|
||||
select value, from: name |
||||
end |
||||
end |
||||
|
||||
def create |
||||
click_button 'Create' |
||||
end |
||||
|
||||
def path |
||||
new_custom_action_path |
||||
end |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue