"copy to clipboard" function implemented

This commit is contained in:
Maria Teresa Paratore 2023-09-26 11:22:59 +02:00
parent daab34df7c
commit cafa1e7ceb
3 changed files with 14 additions and 8 deletions

View File

@ -25,7 +25,7 @@
<mat-label for="uidfield">Context UUID</mat-label>
<input matInput id="uidfield" type="text" placeholder="UUID" formControlName="uidfield" readonly [value]="namefield.value.id" />
</mat-form-field>
<button mat-button (click)="copyUid()" color="primary"><mat-icon class="icon-wide2">content_copy</mat-icon></button>
<button mat-button (click)="copyUid(namefield)" color="primary"><mat-icon class="icon-wide2">content_copy</mat-icon></button>
</form>
</div>
</div>

View File

@ -7,7 +7,7 @@ import { IResource } from 'app/services/i-resource';
import { ContextsLoaderService } from 'app/services/contexts-loader.service';
import { IContextNode } from 'app/services/i-context-node';
import { Observable, map, startWith } from 'rxjs';
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AbstractControl, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { Clipboard } from '@angular/cdk/clipboard';
@Component({
@ -96,15 +96,20 @@ export class RscTreeComponent implements OnInit {
}
}
copyUid(): void {
//const res = this.uidfield ? this.uidfield.value : '';
const res = this.uidfield.value;
this.clipboard.copy(res);
alert(this.uidfield.value);
copyUid(val: any): void {
// const res = this.uidfield ? this.uidfield.value : '';
//const res = this.uidfield.value;
//this.clipboard.copy(res);
if (val instanceof FormControl) {
this.clipboard.copy(val.getRawValue().id);
alert('copied!');
} else {
this.clipboard.copy('invalid value');
}
}
//TODO: modificare per gestire eventuali eventi sulla onselect
assignUid(uid: string): void {
console.debug('------------UUID:.....' + uid);
// console.debug('------------UUID:.....' + uid);
}
}

View File

@ -25,6 +25,7 @@ import { ClipboardModule } from '@angular/cdk/clipboard';
MatAutocompleteModule,
ReactiveFormsModule,
TableScreenComponent,
ClipboardModule,
],
})
export class RscTreeModule {}