mirror of
https://github.com/dev-claw/vripper-project.git
synced 2026-08-19 08:35:41 +02:00
fixes #156
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package me.vripper.gui.view.popup
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty
|
||||
import javafx.geometry.Pos
|
||||
import javafx.scene.control.TextField
|
||||
import javafx.scene.layout.Priority
|
||||
import javafx.scene.layout.VBox
|
||||
import me.vripper.gui.controller.PostController
|
||||
import tornadofx.*
|
||||
|
||||
class RenameView : Fragment("Rename download post") {
|
||||
|
||||
val postId: Long by param()
|
||||
val name: String by param()
|
||||
private val textAreaProperty = SimpleStringProperty()
|
||||
private val postController: PostController by inject()
|
||||
lateinit var input: TextField
|
||||
|
||||
override fun onDock() {
|
||||
textAreaProperty.value = name
|
||||
}
|
||||
|
||||
override val root = vbox(alignment = Pos.CENTER_RIGHT) {
|
||||
padding = insets(all = 5)
|
||||
spacing = 5.0
|
||||
input = textfield {
|
||||
VBox.setVgrow(this, Priority.ALWAYS)
|
||||
bind(textAreaProperty)
|
||||
}
|
||||
button("Ok") {
|
||||
imageview("search.png") {
|
||||
fitWidth = 18.0
|
||||
fitHeight = 18.0
|
||||
}
|
||||
disableWhen(textAreaProperty.isEmpty)
|
||||
action {
|
||||
postController.rename(postId, textAreaProperty.value)
|
||||
close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 632 B |
@@ -0,0 +1,13 @@
|
||||
<h2 mat-dialog-title>Confirmation</h2>
|
||||
<mat-dialog-content class='mat-typography' style='min-width: 30vw'>
|
||||
<form>
|
||||
<mat-form-field appearance='outline' style='width: 100%; padding-top: 20px'>
|
||||
<mat-label>Folder name</mat-label>
|
||||
<input [formControl]='formControl' matInput name='folderName' required />
|
||||
</mat-form-field>
|
||||
</form>
|
||||
<mat-dialog-actions align='end'>
|
||||
<button mat-flat-button mat-dialog-close cdkFocusInitial>Cancel</button>
|
||||
<button mat-flat-button color='primary' (click)='confirm()'>Ok</button>
|
||||
</mat-dialog-actions>
|
||||
</mat-dialog-content>
|
||||
@@ -0,0 +1,21 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { RenameDialogComponent } from './rename-dialog.component';
|
||||
|
||||
describe('ConfirmComponent', () => {
|
||||
let component: RenameDialogComponent;
|
||||
let fixture: ComponentFixture<RenameDialogComponent>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [RenameDialogComponent],
|
||||
});
|
||||
fixture = TestBed.createComponent(RenameDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,53 @@
|
||||
import { ChangeDetectionStrategy, Component, Inject } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import {
|
||||
MAT_DIALOG_DATA,
|
||||
MatDialogModule,
|
||||
MatDialogRef,
|
||||
} from '@angular/material/dialog';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
|
||||
export interface RenameDialogData {
|
||||
postId: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface RenameDialogResult {
|
||||
postId: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-rename-dialog',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
MatDialogModule,
|
||||
MatButtonModule,
|
||||
FormsModule,
|
||||
MatFormFieldModule,
|
||||
MatInputModule,
|
||||
ReactiveFormsModule,
|
||||
],
|
||||
templateUrl: './rename-dialog.component.html',
|
||||
styleUrls: ['./rename-dialog.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class RenameDialogComponent {
|
||||
formControl = new FormControl(this.data.name);
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<RenameDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: RenameDialogData
|
||||
) {}
|
||||
|
||||
confirm() {
|
||||
this.dialogRef.close({
|
||||
postId: this.data.postId,
|
||||
name: this.formControl.value,
|
||||
} as RenameDialogResult);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package me.vripper.web.restendpoints.domain
|
||||
|
||||
data class RenameRequest(val postId: Long, val name: String)
|
||||
Reference in New Issue
Block a user