JHipster 4.14.1: тип ввода = "datetime-local" не привязан - PullRequest
0 голосов
/ 27 мая 2018

Не следует ли поддерживать тип ввода = "datetime-local" для двусторонней привязки данных в приложении JHipster-Angular5?

У меня есть эта простая сущность в моем приложении, сгенерированном JHipster 4.14.1, с использованием Angular5:

entity Product{
    Name String required,
    Description String maxlength(2000),
    Created ZonedDateTime,
    Modified ZonedDateTime
}

и это сгенерированная форма:

<form name="editForm" role="form" novalidate (ngSubmit)="save()" #editForm="ngForm">

        <div class="modal-header">
            <h4 class="modal-title" id="myProductLabel" jhiTranslate="App.Product.home.createOrEditLabel">Create or edit a Product</h4>
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"
                    (click)="clear()">&times;</button>
        </div>
        <div class="modal-body">
            <jhi-alert-error></jhi-alert-error>
            <div class="form-group" [hidden]="!Product.id">
                <label for="id" jhiTranslate="global.field.id">ID</label>
                <input type="text" class="form-control" id="id" name="id"
                       [(ngModel)]="Product.id" readonly />
            </div>
            <div class="form-group">
                <label class="form-control-label" jhiTranslate="App.Product.name" for="field_name">Name</label>
                <input type="text" class="form-control" name="name" id="field_name"
                    [(ngModel)]="Product.name" required/>
                <div [hidden]="!(editForm.controls.name?.dirty && editForm.controls.name?.invalid)">
                    <small class="form-text text-danger"
                       [hidden]="!editForm.controls.name?.errors?.required" jhiTranslate="entity.validation.required">
                       This field is required.
                    </small>
                </div>
            </div>
            <div class="form-group">
                <label class="form-control-label" jhiTranslate="App.Product.description" for="field_description">Description</label>
                <input type="text" class="form-control" name="description" id="field_description"
                    [(ngModel)]="Product.description" maxlength="2000"/>
                <div [hidden]="!(editForm.controls.description?.dirty && editForm.controls.description?.invalid)">
                    <small class="form-text text-danger"
                       [hidden]="!editForm.controls.description?.errors?.maxlength" jhiTranslate="entity.validation.maxlength" translateValues="{ max: 2000 }">
                       This field cannot be longer than 2000 characters.
                    </small>
                </div>
            </div>
            <div class="form-group">
                <label class="form-control-label" jhiTranslate="App.Product.created" for="field_created">Created</label>
                <div class="d-flex">
                    <input id="field_created" type="datetime-local" class="form-control" name="created" [(ngModel)]="Product.created"
                    />
                </div>
            </div>
            <div class="form-group">
                <label class="form-control-label" jhiTranslate="App.Product.modified" for="field_modified">Modified</label>
                <div class="d-flex">
                    <input id="field_modified" type="datetime-local" class="form-control" name="modified" [(ngModel)]="Product.modified"
                    />
                </div>
            </div>
            <div class="form-group">
                <label class="form-control-label" jhiTranslate="App.Product.type" for="field_type">Type</label>
                <select class="form-control" name="type" [(ngModel)]="Product.type" id="field_type" >
                    <option value="IT">{{'App.ProductType.INFORMATION' | translate}}</option>
                    <option value="HEALTHCARE">{{'App.ProductType.HEALTHCARE' | translate}}</option>
                </select>
            </div>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-dismiss="modal" (click)="clear()">
                <span class="fa fa-ban"></span>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
            </button>
            <button type="submit" [disabled]="editForm.form.invalid || isSaving" class="btn btn-primary">
                <span class="fa fa-save"></span>&nbsp;<span jhiTranslate="entity.action.save">Save</span>
            </button>
        </div>
    </form>

Однако, когда я пытаюсь сохранить Продукт, созданные и измененные поля передаются как пустые в вызове POST.

{  
   "name":"Product",
   "description":"Product Description",
   "created":null,
   "modified":null,
   "type":"IT"
}

Как я могу это исправить?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...