Skip to content

Commit

Permalink
Merge pull request #14683 from opf/housekeeping/bump-primer
Browse files Browse the repository at this point in the history
Update Primer to version 0.22.2
  • Loading branch information
oliverguenther authored Feb 18, 2024
2 parents 42ebaba + d9985aa commit 622ba72
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 68 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -382,4 +382,4 @@ end

gem 'openproject-octicons', '~>19.8.0'
gem 'openproject-octicons_helper', '~>19.8.0'
gem 'openproject-primer_view_components', '~>0.20.0'
gem 'openproject-primer_view_components', '~>0.22.2'
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ GEM
actionview
openproject-octicons (= 19.8.0)
railties
openproject-primer_view_components (0.20.0)
openproject-primer_view_components (0.22.2)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
openproject-octicons (>= 19.8.0)
Expand Down Expand Up @@ -1227,7 +1227,7 @@ DEPENDENCIES
openproject-octicons (~> 19.8.0)
openproject-octicons_helper (~> 19.8.0)
openproject-openid_connect!
openproject-primer_view_components (~> 0.20.0)
openproject-primer_view_components (~> 0.22.2)
openproject-recaptcha!
openproject-reporting!
openproject-storages!
Expand Down
3 changes: 2 additions & 1 deletion app/views/augmented/_autocomplete_select_decoration.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<%= content_tag :'opce-select-decoration',
{},
data: {
"multiselect": multiple,
multiple:,
"input-name": input_name,
"input-id": input_id,
"append-to": defined?(append_to) ? append_to : 'body',
key:,
options: JSON.dump(select_options),
} %>
Expand Down
48 changes: 24 additions & 24 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"@ngneat/content-loader": "^7.0.0",
"@ngx-formly/core": "^6.1.4",
"@openproject/octicons-angular": "^19.8.0",
"@openproject/primer-view-components": "^0.20.0",
"@openproject/primer-view-components": "^0.22.2",
"@openproject/reactivestates": "^3.0.1",
"@primer/css": "^21.1.1",
"@uirouter/angular": "^12.0.0",
Expand Down Expand Up @@ -175,6 +175,6 @@
"generate-typings": "tsc -d -p src/tsconfig.app.json"
},
"overrides": {
"@primer/view-components": "npm:@openproject/primer-view-components@^0.20.0"
"@primer/view-components": "npm:@openproject/primer-view-components@^0.22.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@
//++

import {
Component, ElementRef, OnInit, ViewChild,
AfterViewInit,
Component,
OnInit,
ViewChild,
} from '@angular/core';
import { NgSelectComponent } from '@ng-select/ng-select';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
import { IProjectAutocompleterData } from 'core-app/shared/components/autocompleter/project-autocompleter/project-autocompleter.component';
import { IProjectAutocompleteItem } from 'core-app/shared/components/autocompleter/project-autocompleter/project-autocomplete-item';
import {
IAutocompleteItem,
OpAutocompleterComponent,
} from 'core-app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component';

type SelectItem = { label:string, value:string, selected?:boolean };

Expand All @@ -44,10 +48,10 @@ export const autocompleteSelectDecorationSelector = 'autocomplete-select-decorat
<op-project-autocompleter
*ngIf="isProjectField()"
[model]="currentProjectSelection"
[multiple]="multiselect"
[multiple]="multiple"
[labelForId]="labelForId"
(change)="updateProjectSelection($event)"
appendTo="body"
[appendTo]="appendTo"
>
</op-project-autocompleter>
Expand All @@ -56,10 +60,10 @@ export const autocompleteSelectDecorationSelector = 'autocomplete-select-decorat
[items]="options"
[labelForId]="labelForId"
bindLabel="label"
[multiple]="multiselect"
[multiple]="multiple"
[virtualScroll]="true"
[ngModel]="selected"
appendTo="body"
[appendTo]="appendTo"
[placeholder]="text.placeholder"
(ngModelChange)="updateSelection($event)">
<ng-template ng-option-tmp let-item="item" let-index="index">
Expand All @@ -69,14 +73,11 @@ export const autocompleteSelectDecorationSelector = 'autocomplete-select-decorat
`,
selector: autocompleteSelectDecorationSelector,
})
export class AutocompleteSelectDecorationComponent implements OnInit {
export class AutocompleteSelectDecorationComponent extends OpAutocompleterComponent<IAutocompleteItem> implements OnInit, AfterViewInit {
@ViewChild(NgSelectComponent) public ngSelectComponent:NgSelectComponent;

public options:SelectItem[];

/** Whether we're a multiselect */
public multiselect = false;

/** Get the selected options */
public selected:SelectItem|SelectItem[];

Expand All @@ -86,34 +87,26 @@ export class AutocompleteSelectDecorationComponent implements OnInit {
/** The input name we're syncing selections to */
private syncInputFieldName:string;

/** The input id used for label */
public labelForId:string;

/** The field key (e.g. status, type, or project) */
public key:string;

text = {
placeholder: this.I18n.t('js.placeholders.selection'),
};

constructor(
protected elementRef:ElementRef,
readonly I18n:I18nService,
) {
}

ngOnInit():void {
const element = this.elementRef.nativeElement as HTMLElement;

// Set options
this.multiselect = element.dataset.multiselect === 'true';
this.labelForId = element.dataset.inputId!;
this.multiple = element.dataset.multiple === 'true';
this.labelForId = element.dataset.inputId;
this.key = element.dataset.key!;
this.appendTo = element.dataset.appendTo;

// Get the sync target
this.syncInputFieldName = element.dataset.inputName!;
// Add Rails multiple identifier if multiselect
if (this.multiselect) {
// Add Rails multiple identifier if multiple
if (this.multiple) {
this.syncInputFieldName += '[]';
}

Expand All @@ -127,7 +120,7 @@ export class AutocompleteSelectDecorationComponent implements OnInit {
this.setInitialProjectSelection();
}

if (!this.multiselect) {
if (!this.multiple) {
this.selected = (this.selected as SelectItem[])[0];
}

Expand All @@ -137,6 +130,11 @@ export class AutocompleteSelectDecorationComponent implements OnInit {
element.parentElement!.hidden = false;
}

// eslint-disable-next-line @angular-eslint/no-empty-lifecycle-method
ngAfterViewInit():void {
// do nothing and prevent the parent hook to be called
}

setInitialSelection(data:SelectItem[]):void {
this.updateSelection(data.filter((element) => element.selected));
}
Expand Down Expand Up @@ -185,7 +183,7 @@ export class AutocompleteSelectDecorationComponent implements OnInit {
const items = _.castArray(this.selected);
if (items.length === 0) return;

if (this.multiselect) {
if (this.multiple) {
this.currentProjectSelection = items.map((item:SelectItem) => ({
id: item.value,
name: item.label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class OpAutocompleterComponent<T extends IAutocompleteItem = IAutocomplet

@Input() public clearOnBackspace?:boolean = true;

@Input() public labelForId ? = null;
@Input() public labelForId?:string;

@Input() public inputAttrs?:{ [key:string]:string } = {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
*/

import { Controller } from '@hotwired/stimulus';
import { ModalDialogElement } from '@openproject/primer-view-components/app/components/primer/alpha/modal_dialog';

export default class OAuthAccessGrantNudgeModalController extends Controller<ModalDialogElement> {
export default class OAuthAccessGrantNudgeModalController extends Controller<HTMLDialogElement> {
connect() {
this.element.open = true;
this.element.showModal();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@

import { Controller } from '@hotwired/stimulus';
import { renderStreamMessage } from '@hotwired/turbo';
import { ModalDialogElement } from '@openproject/primer-view-components/app/components/primer/alpha/modal_dialog';

export default class OpenProjectStorageModalController extends Controller<ModalDialogElement> {
export default class OpenProjectStorageModalController extends Controller<HTMLDialogElement> {
static values = {
projectStorageOpenUrl: String,
redirectUrl: String,
Expand All @@ -43,7 +42,7 @@ export default class OpenProjectStorageModalController extends Controller<ModalD
redirectUrlValue:string;

connect() {
this.element.open = true;
this.element.showModal();
this.interval = 0;
this.load();
this.element.addEventListener('close', () => { this.disconnect(); });
Expand Down
3 changes: 2 additions & 1 deletion lib/primer/open_project/forms/autocompleter.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
input_id: builder.field_id(@input.name),
select_options: select_options.map(&:to_h),
multiple: @autocomplete_options.fetch(:multiple, false),
key: @autocomplete_options.fetch(:resource, '')
key: @autocomplete_options.fetch(:resource, ''),
append_to: @autocomplete_options.fetch(:append_to, 'body')
} %>
<% else %>
<%= angular_component_tag 'opce-autocompleter',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
end
end
flex.with_row do
render(MeetingAgendaItem::MeetingForm.new(f))
render(MeetingAgendaItem::MeetingForm.new(f, wrapper_id: 'add-work-package-to-meeting-dialog'))
end
flex.with_row(mt: 3) do
render(MeetingAgendaItem::Notes.new(f))
Expand Down
Loading

0 comments on commit 622ba72

Please sign in to comment.