Skip to content

feat(i18n): remove text resources from components #142

Merged
merged 4 commits into from
Jun 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions packages/mosaic-dev/dateformatter/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ export class DemoComponent {
enRangeShortDateTimeEndsNotCurrentYear: string;

// tslint:disable-next-line:max-func-body-length
constructor(
@Inject(DateAdapter) public dateAdapter: DateAdapter<Moment>
) {
constructor(private dateAdapter: DateAdapter<Moment>) {
this.populateRuLongDate();
this.populateEnLongDate();

Expand Down Expand Up @@ -471,14 +469,8 @@ export class DemoComponent {
DemoComponent
],
imports: [
BrowserAnimationsModule,
BrowserModule,
FormsModule,
McFormFieldModule,
McDatepickerModule,
McMomentDateModule,
McInputModule,
McIconModule
McMomentDateModule
],
bootstrap: [
DemoComponent
Expand Down
6 changes: 5 additions & 1 deletion packages/mosaic-dev/select/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@
<mc-select [(value)]="singleSelectedWithSearch">
<mc-form-field mcFormFieldWithoutBorders mcSelectSearch>
<i mcPrefix mc-icon="mc-search_16"></i>
<input mcInput [formControl]="searchCtrl" type="text" placeholder="Search" />
<input mcInput [formControl]="searchCtrl" type="text" placeholder="Search"/>
<mc-cleaner></mc-cleaner>
</mc-form-field>

<div mc-select-search-empty-result>Ничего не найдено</div>

<mc-option *ngFor="let option of filteredOptions | async" [value]="option">{{ option }}</mc-option>
</mc-select>
</mc-form-field>
Expand All @@ -59,6 +61,8 @@
<mc-cleaner></mc-cleaner>
</mc-form-field>

<div mc-select-search-empty-result>Ничего не найдено</div>

<mc-option *ngFor="let option of filteredMultipleOptions | async" [value]="option">{{ option }}</mc-option>
</mc-select>
</mc-form-field>
Expand Down
23 changes: 14 additions & 9 deletions packages/mosaic/select/select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export class McSelectBase {
const McSelectMixinBase: CanDisableCtor & HasTabIndexCtor & CanUpdateErrorStateCtor &
typeof McSelectBase = mixinTabIndex(mixinDisabled(mixinErrorState(McSelectBase)));


@Directive({
selector: '[mcSelectSearch]',
exportAs: 'mcSelectSearch',
Expand Down Expand Up @@ -176,6 +177,13 @@ export class McSelectSearch implements AfterContentInit, OnDestroy {
}


@Directive({
selector: '[mc-select-search-empty-result]',
exportAs: 'mcSelectSearchEmptyResult'
})
export class McSelectSearchEmptyResult {}


@Directive({ selector: 'mc-select-trigger' })
export class McSelectTrigger {}

Expand Down Expand Up @@ -217,9 +225,6 @@ export class McSelect extends McSelectMixinBase implements
controlType = 'mc-select';

hiddenItems: number = 0;
// todo localization
oneMoreText: string = '...ещё';
noOptionsText: string = 'Ничего не найдено';

/** The last measured value for the trigger's client bounding rect. */
triggerRect: ClientRect;
Expand Down Expand Up @@ -297,7 +302,9 @@ export class McSelect extends McSelectMixinBase implements
/** All of the defined groups of options. */
@ContentChildren(McOptgroup) optionGroups: QueryList<McOptgroup>;

@ContentChild(McSelectSearch, {static: false}) search: McSelectSearch;
@ContentChild(McSelectSearch, { static: false }) search: McSelectSearch;

@Input() hiddenItemsText: string = '...ещё';

/** Classes to be passed to the select panel. Supports the same syntax as `ngClass`. */
@Input() panelClass: string | string[] | Set<string> | { [key: string]: any };
Expand Down Expand Up @@ -457,14 +464,12 @@ export class McSelect extends McSelectMixinBase implements
return this._panelOpen;
}

private _panelOpen = false;

get isEmptySearchResult(): boolean {
return this.search &&
this.options.length === 0 &&
!!this.search.input.value;
return this.search && this.options.length === 0 && !!this.search.input.value;
}

private _panelOpen = false;

/** The scroll position of the overlay panel, calculated to center the selected option. */
private scrollTop = 0;

Expand Down
15 changes: 8 additions & 7 deletions packages/mosaic/select/select.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</mc-tag>
</div>
<div class="mc-select__match-hidden-text" [style.display]="hiddenItems > 0 ? 'block' : 'none'">
{{ oneMoreText }} {{ hiddenItems }}
{{ hiddenItemsText }} {{ hiddenItems }}
</div>
</div>
<ng-content select="mc-select-trigger" *ngSwitchCase="true"></ng-content>
Expand Down Expand Up @@ -56,13 +56,14 @@
<ng-content select="[mcSelectSearch]"></ng-content>
</div>

<div
#optionsContainer
class="mc-select__content"
[@fadeInContent]="'showing'"
(@fadeInContent.done)="onFadeInDone()">
<div #optionsContainer
class="mc-select__content"
[@fadeInContent]="'showing'"
(@fadeInContent.done)="onFadeInDone()">

<div *ngIf="isEmptySearchResult" class="mc-select__no-options-message">{{noOptionsText}}</div>
<div *ngIf="isEmptySearchResult" class="mc-select__no-options-message">
<ng-content select="[mc-select-search-empty-result]"></ng-content>
</div>
<ng-content select="mc-option,mc-optgroup"></ng-content>
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion packages/mosaic/select/select.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { McFormFieldModule } from '@ptsecurity/mosaic/form-field';
import { McIconModule } from '@ptsecurity/mosaic/icon';
import { McTagsModule } from '@ptsecurity/mosaic/tags';

import { McSelect, McSelectSearch, McSelectTrigger } from './select.component';
import { McSelect, McSelectSearch, McSelectSearchEmptyResult, McSelectTrigger } from './select.component';


@NgModule({
Expand All @@ -21,13 +21,15 @@ import { McSelect, McSelectSearch, McSelectTrigger } from './select.component';
McFormFieldModule,
McSelect,
McSelectSearch,
McSelectSearchEmptyResult,
McSelectTrigger,
McOptionModule,
CommonModule
],
declarations: [
McSelect,
McSelectSearch,
McSelectSearchEmptyResult,
McSelectTrigger],
providers: [MC_SELECT_SCROLL_STRATEGY_PROVIDER]
})
Expand Down
3 changes: 2 additions & 1 deletion packages/mosaic/tree-select/tree-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ export class McTreeSelect extends McTreeSelectMixinBase implements
controlType = 'mc-select';

hiddenItems: number = 0;
oneMoreText: string = '...ещё';

/** The last measured value for the trigger's client bounding rect. */
triggerRect: ClientRect;
Expand Down Expand Up @@ -220,6 +219,8 @@ export class McTreeSelect extends McTreeSelectMixinBase implements

@ContentChild(McTreeSelection, {static: false}) tree: McTreeSelection;

@Input() hiddenItemsText: string = '...ещё';

/** Event emitted when the select panel has been toggled. */
@Output() readonly openedChange: EventEmitter<boolean> = new EventEmitter<boolean>();

Expand Down
2 changes: 1 addition & 1 deletion packages/mosaic/tree-select/tree-select.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</mc-tag>
</div>
<div class="mc-tree-select__match-hidden-text" [style.display]="hiddenItems > 0 ? 'block' : 'none'">
{{ oneMoreText }} {{ hiddenItems }}
{{ hiddenItemsText }} {{ hiddenItems }}
</div>
</div>
<ng-content select="mc-select-trigger" *ngSwitchCase="true"></ng-content>
Expand Down