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 />
<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 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.

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

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

Loading…
Cancel
Save