Skip to content

Commit

Permalink
#32: adjsust display of selected asset for 1018 ui (#33)
Browse files Browse the repository at this point in the history
Co-authored-by: Dirk Peter <dirk.peter@softwareg.com>
  • Loading branch information
dirk-peter-c8y and Dirk Peter authored Jul 22, 2024
1 parent 73a9c33 commit 50fc0d5
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 19 deletions.
38 changes: 24 additions & 14 deletions plugin/components/asset.formly/asset.formly.component.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
<c8y-asset-selector-miller
class="m-b-24"
[selectedDevice]="field.props.asset"
[config]="{
groupsSelectable: true,
singleColumn: true,
columnHeaders: true,
showFilter: true,
search: true,
label: field.props.label
}"
[formControl]="formControl"
[formlyAttributes]="field">
</c8y-asset-selector-miller>
<ng-container *ngIf="!model.source; else assetDetails">
<c8y-asset-selector-miller class="m-b-24" [selectedDevice]="field.props.asset" [config]="{
groupsSelectable: true,
singleColumn: true,
columnHeaders: true,
showFilter: true,
search: true,
label: field.props.label
}" [formControl]="formControl" [formlyAttributes]="field">
</c8y-asset-selector-miller>
</ng-container>

<ng-template #assetDetails>
<div class="form-group no-asset">
<label>Selected asset</label>

<div class="d-flex">
<span>
{{ model.source.name }} <span class="text-muted">#{{ model.source.id }}</span>
</span>
<button type="button" class="btn btn-primary" (click)="clearSelection()">{{ 'Change' | translate }}</button>
</div>
</div>
</ng-template>
49 changes: 46 additions & 3 deletions plugin/components/asset.formly/asset.formly.component.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,49 @@
:host ::ng-deep {
.miller-column__selection {
padding-left: 0 !important;
padding-right: 0 !important;
.miller-view-wrapper{
position: relative;
margin-bottom: 24px;

.miller-column__header {
position: relative;
margin-top: 34px !important;
align-items: center;
justify-content: space-between;

p {
margin: 0 !important;
}

> :nth-child(2) {
position: absolute;
top: 3em;
right: 8px;
left: 8px;
}
}

.miller-column {
c8y-asset-selector > div {
display: flex;
}

.p-absolute {
left: 0;
right: 0;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 0 4px !important;
}

+ .miller-column .miller-column__header {
margin-top: 0 !important;
padding-bottom: 3.1rem;
}
}
}
}

.no-asset div {
justify-content: space-between;
align-items: center;
}
8 changes: 7 additions & 1 deletion plugin/components/asset.formly/asset.formly.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ import { FieldType, FieldTypeConfig } from '@ngx-formly/core';
templateUrl: './asset.formly.component.html',
styleUrls: ['./asset.formly.component.less']
})
export class AssetFieldType extends FieldType<FieldTypeConfig> {}
export class AssetFieldType extends FieldType<FieldTypeConfig> {
clearSelection(): void {
this.formControl.setValue(null);
this.formControl.markAsDirty();
this.options.updateInitialValue({});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:host {
.form-group label {
white-space: normal !important;
}
}
3 changes: 2 additions & 1 deletion plugin/components/reminder-modal/reminder-modal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { Reminder, ReminderStatus, REMINDER_TEXT_LENGTH, REMINDER_TYPE } from '.

@Component({
selector: 'c8y-reminder-modal',
templateUrl: './reminder-modal.component.html'
templateUrl: './reminder-modal.component.html',
styleUrls: ['./reminder-modal.component.less']
})
export class ReminderModalComponent implements OnInit {
isLoading = false;
Expand Down

0 comments on commit 50fc0d5

Please sign in to comment.