Browse Source

Fixed creating schemas.

pull/164/head
Sebastian Stehle 8 years ago
parent
commit
dd6f2bd2a9
  1. 2
      src/Squidex/app/features/schemas/pages/schemas/schema-form.component.html
  2. 18
      src/Squidex/app/features/schemas/pages/schemas/schema-form.component.ts

2
src/Squidex/app/features/schemas/pages/schemas/schema-form.component.html

@ -13,7 +13,7 @@
<input type="text" class="form-control" id="schema-name" formControlName="name" autocomplete="off" sqxLowerCaseInput sqxFocusOnInit /> <input type="text" class="form-control" id="schema-name" formControlName="name" autocomplete="off" sqxLowerCaseInput sqxFocusOnInit />
<small class="form-text text-muted"> <small class="form-text text-muted">
The schema name becomes part of the api url,<br /> e.g {{apiUrl.buildUrl("api/content/")}}{{appName}}/<b>{{schemaName | async}}</b>/. The schema name becomes part of the api url,<br /> e.g {{apiUrl.buildUrl("api/content/")}}{{ctx.appName}}/<b>{{schemaName | async}}</b>/.
</small> </small>
<small class="form-text text-muted"> <small class="form-text text-muted">
It must contain lower case letters (a-z), numbers and dashes only, and cannot be longer than 40 characters. The name cannot be changed later. It must contain lower case letters (a-z), numbers and dashes only, and cannot be longer than 40 characters. The name cannot be changed later.

18
src/Squidex/app/features/schemas/pages/schemas/schema-form.component.ts

@ -5,12 +5,12 @@
* Copyright (c) Sebastian Stehle. All rights reserved * Copyright (c) Sebastian Stehle. All rights reserved
*/ */
import { Component, EventEmitter, Input, Output } from '@angular/core'; import { Component, EventEmitter, Output } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms'; import { FormBuilder, Validators } from '@angular/forms';
import { import {
ApiUrlConfig, ApiUrlConfig,
AuthService, AppContext,
DateTime, DateTime,
fadeAnimation, fadeAnimation,
SchemaDetailsDto, SchemaDetailsDto,
@ -24,6 +24,9 @@ const FALLBACK_NAME = 'my-schema';
selector: 'sqx-schema-form', selector: 'sqx-schema-form',
styleUrls: ['./schema-form.component.scss'], styleUrls: ['./schema-form.component.scss'],
templateUrl: './schema-form.component.html', templateUrl: './schema-form.component.html',
providers: [
AppContext
],
animations: [ animations: [
fadeAnimation fadeAnimation
] ]
@ -35,9 +38,6 @@ export class SchemaFormComponent {
@Output() @Output()
public cancelled = new EventEmitter(); public cancelled = new EventEmitter();
@Input()
public appName: string;
public showImport = false; public showImport = false;
public createFormError = ''; public createFormError = '';
@ -59,9 +59,9 @@ export class SchemaFormComponent {
constructor( constructor(
public readonly apiUrl: ApiUrlConfig, public readonly apiUrl: ApiUrlConfig,
public readonly ctx: AppContext,
private readonly schemas: SchemasService, private readonly schemas: SchemasService,
private readonly formBuilder: FormBuilder, private readonly formBuilder: FormBuilder
private readonly authService: AuthService
) { ) {
} }
@ -85,9 +85,7 @@ export class SchemaFormComponent {
const schemaName = this.createForm.controls['name'].value; const schemaName = this.createForm.controls['name'].value;
const schemaDto = Object.assign(this.createForm.controls['import'].value || {}, { name: schemaName }); const schemaDto = Object.assign(this.createForm.controls['import'].value || {}, { name: schemaName });
const me = this.authService.user!.token; this.schemas.postSchema(this.ctx.appName, schemaDto, this.ctx.userToken, DateTime.now())
this.schemas.postSchema(this.appName, schemaDto, me, DateTime.now())
.subscribe(dto => { .subscribe(dto => {
this.emitCreated(dto); this.emitCreated(dto);
this.resetCreateForm(); this.resetCreateForm();

Loading…
Cancel
Save