Browse Source

Observable fixes

pull/1/head
Sebastian 10 years ago
parent
commit
8e9e1ea5d0
  1. 12
      src/Squidex/app/features/content/pages/content/content-page.component.ts
  2. 12
      src/Squidex/app/features/content/pages/contents/contents-page.component.ts
  3. 4
      src/Squidex/app/features/content/pages/schemas/schemas-page.component.ts
  4. 3
      src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts
  5. 4
      src/Squidex/app/features/schemas/pages/schema/types/boolean-validation.component.ts
  6. 4
      src/Squidex/app/features/schemas/pages/schema/types/date-time-validation.component.ts
  7. 4
      src/Squidex/app/features/schemas/pages/schema/types/number-ui.component.ts
  8. 4
      src/Squidex/app/features/schemas/pages/schema/types/number-validation.component.ts
  9. 7
      src/Squidex/app/features/schemas/pages/schema/types/string-ui.component.ts
  10. 8
      src/Squidex/app/features/schemas/pages/schema/types/string-validation.component.ts
  11. 5
      src/Squidex/app/features/schemas/pages/schemas/schema-form.component.ts
  12. 3
      src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts
  13. 3
      src/Squidex/app/framework/angular/json-editor.component.ts
  14. 5
      src/Squidex/app/shared/components/app-form.component.ts
  15. 3
      src/Squidex/app/shared/services/apps-store.service.ts
  16. 3
      src/Squidex/app/shell/pages/internal/profile-menu.component.ts
  17. 3
      src/Squidex/app/shell/pages/login/login-page.component.ts
  18. 3
      src/Squidex/app/shell/pages/logout/logout-page.component.ts

12
src/Squidex/app/features/content/pages/content/content-page.component.ts

@ -67,21 +67,25 @@ export class ContentPageComponent extends AppComponentBase implements OnDestroy,
public ngOnInit() { public ngOnInit() {
this.messageSubscription = this.messageSubscription =
this.messageBus.of(ContentDeleted).subscribe(message => { this.messageBus.of(ContentDeleted)
.subscribe(message => {
if (message.id === this.contentId) { if (message.id === this.contentId) {
this.router.navigate(['../'], { relativeTo: this.route }); this.router.navigate(['../'], { relativeTo: this.route });
} }
}); });
this.route.parent.data.map(p => p['appLanguages']).subscribe((languages: AppLanguageDto[]) => { this.route.parent.data.map(p => p['appLanguages'])
.subscribe((languages: AppLanguageDto[]) => {
this.languages = languages; this.languages = languages;
}); });
this.route.parent.data.map(p => p['schema']).subscribe((schema: SchemaDetailsDto) => { this.route.parent.data.map(p => p['schema'])
.subscribe((schema: SchemaDetailsDto) => {
this.setupForm(schema); this.setupForm(schema);
}); });
this.route.data.map(p => p['content']).subscribe((content: ContentDto) => { this.route.data.map(p => p['content'])
.subscribe((content: ContentDto) => {
this.populateForm(content); this.populateForm(content);
}); });
} }

12
src/Squidex/app/features/content/pages/contents/contents-page.component.ts

@ -84,22 +84,26 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy
public ngOnInit() { public ngOnInit() {
this.messageCreatedSubscription = this.messageCreatedSubscription =
this.messageBus.of(ContentCreated).subscribe(message => { this.messageBus.of(ContentCreated)
.subscribe(message => {
this.itemLast++; this.itemLast++;
this.contentTotal++; this.contentTotal++;
this.contentItems = this.contentItems.pushFront(this.createContent(message.id, message.data, message.version)); this.contentItems = this.contentItems.pushFront(this.createContent(message.id, message.data, message.version));
}); });
this.messageUpdatedSubscription = this.messageUpdatedSubscription =
this.messageBus.of(ContentUpdated).subscribe(message => { this.messageBus.of(ContentUpdated)
.subscribe(message => {
this.updateContents(message.id, undefined, message.data, message.version); this.updateContents(message.id, undefined, message.data, message.version);
}); });
this.route.data.map(p => p['appLanguages']).subscribe((languages: AppLanguageDto[]) => { this.route.data.map(p => p['appLanguages'])
.subscribe((languages: AppLanguageDto[]) => {
this.languages = languages; this.languages = languages;
}); });
this.route.data.map(p => p['schema']).subscribe(schema => { this.route.data.map(p => p['schema'])
.subscribe(schema => {
this.schema = schema; this.schema = schema;
this.reset(); this.reset();

4
src/Squidex/app/features/content/pages/schemas/schemas-page.component.ts

@ -26,8 +26,8 @@ import {
export class SchemasPageComponent extends AppComponentBase { export class SchemasPageComponent extends AppComponentBase {
public schemasFilter = new FormControl(); public schemasFilter = new FormControl();
public schemasFiltered = public schemasFiltered =
Observable.of(null) this.schemasFilter.valueChanges
.merge(this.schemasFilter.valueChanges) .startWith(null)
.distinctUntilChanged() .distinctUntilChanged()
.debounceTime(300) .debounceTime(300)
.combineLatest(this.loadSchemas(), .combineLatest(this.loadSchemas(),

3
src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts

@ -84,7 +84,8 @@ export class SchemaPageComponent extends AppComponentBase implements OnInit {
} }
public ngOnInit() { public ngOnInit() {
this.route.data.map(p => p['schema']).subscribe((schema: SchemaDetailsDto) => { this.route.data.map(p => p['schema'])
.subscribe((schema: SchemaDetailsDto) => {
this.schemaName = schema.name; this.schemaName = schema.name;
this.schemaFields = ImmutableArray.of(schema.fields); this.schemaFields = ImmutableArray.of(schema.fields);
this.schemaProperties = new SchemaPropertiesDto(schema.name, schema.label, schema.hints); this.schemaProperties = new SchemaPropertiesDto(schema.name, schema.label, schema.hints);

4
src/Squidex/app/features/schemas/pages/schema/types/boolean-validation.component.ts

@ -30,8 +30,8 @@ export class BooleanValidationComponent implements OnInit {
new FormControl(this.properties.defaultValue)); new FormControl(this.properties.defaultValue));
this.hideDefaultValue = this.hideDefaultValue =
Observable.of(this.properties.isRequired) this.editForm.get('isRequired').valueChanges
.merge(this.editForm.get('isRequired').valueChanges) .startWith(this.properties.isRequired)
.map(x => !!x); .map(x => !!x);
} }
} }

4
src/Squidex/app/features/schemas/pages/schema/types/date-time-validation.component.ts

@ -42,8 +42,8 @@ export class DateTimeValidationComponent implements OnInit {
])); ]));
this.hideDefaultValue = this.hideDefaultValue =
Observable.of(this.properties.isRequired) this.editForm.get('isRequired').valueChanges
.merge(this.editForm.get('isRequired').valueChanges) .startWith(this.properties.isRequired)
.map(x => !!x); .map(x => !!x);
} }
} }

4
src/Squidex/app/features/schemas/pages/schema/types/number-ui.component.ts

@ -46,8 +46,8 @@ export class NumberUIComponent implements OnDestroy, OnInit {
new FormControl(this.properties.allowedValues, [])); new FormControl(this.properties.allowedValues, []));
this.hideAllowedValues = this.hideAllowedValues =
Observable.of(this.properties.editor) this.editForm.get('editor').valueChanges
.merge(this.editForm.get('editor').valueChanges) .startWith(this.properties.editor)
.map(x => !x || x === 'Input' || x === 'Textarea'); .map(x => !x || x === 'Input' || x === 'Textarea');
this.editorSubscription = this.editorSubscription =

4
src/Squidex/app/features/schemas/pages/schema/types/number-validation.component.ts

@ -36,8 +36,8 @@ export class NumberValidationComponent implements OnInit {
new FormControl(this.properties.defaultValue)); new FormControl(this.properties.defaultValue));
this.hideDefaultValue = this.hideDefaultValue =
Observable.of(this.properties.isRequired) this.editForm.get('isRequired').valueChanges
.merge(this.editForm.get('isRequired').valueChanges) .startWith(this.properties.isRequired)
.map(x => !!x); .map(x => !!x);
} }
} }

7
src/Squidex/app/features/schemas/pages/schema/types/string-ui.component.ts

@ -46,12 +46,13 @@ export class StringUIComponent implements OnDestroy, OnInit {
new FormControl(this.properties.allowedValues)); new FormControl(this.properties.allowedValues));
this.hideAllowedValues = this.hideAllowedValues =
Observable.of(this.properties.editor) this.editForm.get('editor').valueChanges
.merge(this.editForm.get('editor').valueChanges) .startWith(this.properties.editor)
.map(x => !x || x === 'Input' || x === 'TextArea' || x === 'RichText' || x === 'Markdown'); .map(x => !x || x === 'Input' || x === 'TextArea' || x === 'RichText' || x === 'Markdown');
this.editorSubscription = this.editorSubscription =
this.hideAllowedValues.subscribe(isSelection => { this.hideAllowedValues
.subscribe(isSelection => {
if (isSelection) { if (isSelection) {
this.editForm.get('allowedValues').setValue(undefined); this.editForm.get('allowedValues').setValue(undefined);
} }

8
src/Squidex/app/features/schemas/pages/schema/types/string-validation.component.ts

@ -49,13 +49,13 @@ export class StringValidationComponent implements OnDestroy, OnInit {
new FormControl(this.properties.defaultValue)); new FormControl(this.properties.defaultValue));
this.hideDefaultValue = this.hideDefaultValue =
Observable.of(false) this.editForm.get('isRequired').valueChanges
.merge(this.editForm.get('isRequired').valueChanges) .startWith(this.properties.isRequired)
.map(x => !!x); .map(x => !!x);
this.hidePatternMessage = this.hidePatternMessage =
Observable.of(false) this.editForm.get('pattern').valueChanges
.merge(this.editForm.get('pattern').valueChanges) .startWith('')
.map(x => !x || x.trim().length === 0); .map(x => !x || x.trim().length === 0);
this.patternSubscription = this.patternSubscription =

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

@ -7,7 +7,6 @@
import { Component, EventEmitter, Input, Output } from '@angular/core'; import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Observable } from 'rxjs';
import { import {
ApiUrlConfig, ApiUrlConfig,
@ -54,8 +53,8 @@ export class SchemaFormComponent {
}); });
public schemaName = public schemaName =
Observable.of(FALLBACK_NAME) this.createForm.get('name').valueChanges.map(n => n || FALLBACK_NAME)
.merge(this.createForm.get('name').valueChanges.map(n => n || FALLBACK_NAME)); .startWith(FALLBACK_NAME);
constructor( constructor(
public readonly apiUrl: ApiUrlConfig, public readonly apiUrl: ApiUrlConfig,

3
src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts

@ -67,7 +67,8 @@ export class SchemasPageComponent extends AppComponentBase implements OnDestroy,
this.updateSchemas(this.schemas, this.schemaQuery = q); this.updateSchemas(this.schemas, this.schemaQuery = q);
}); });
this.route.params.map(q => q['showDialog']).subscribe(showDialog => { this.route.params.map(q => q['showDialog'])
.subscribe(showDialog => {
if (showDialog) { if (showDialog) {
this.addSchemaDialog.show(); this.addSchemaDialog.show();
} }

3
src/Squidex/app/framework/angular/json-editor.component.ts

@ -67,7 +67,8 @@ export class JsonEditorComponent implements ControlValueAccessor, AfterViewInit
} }
public ngAfterViewInit() { public ngAfterViewInit() {
this.valueChanged.debounceTime(1000).subscribe(() => { this.valueChanged.debounceTime(1000)
.subscribe(() => {
const isValid = this.aceEditor.getSession().getAnnotations().length === 0; const isValid = this.aceEditor.getSession().getAnnotations().length === 0;
if (!isValid) { if (!isValid) {

5
src/Squidex/app/shared/components/app-form.component.ts

@ -7,7 +7,6 @@
import { Component, EventEmitter, Output } from '@angular/core'; import { Component, EventEmitter, Output } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Observable } from 'rxjs';
import { ApiUrlConfig, ValidatorsEx } from 'framework'; import { ApiUrlConfig, ValidatorsEx } from 'framework';
@ -41,8 +40,8 @@ export class AppFormComponent {
}); });
public appName = public appName =
Observable.of(FALLBACK_NAME) this.createForm.get('name').valueChanges.map(n => n || FALLBACK_NAME)
.merge(this.createForm.get('name').valueChanges.map(n => n || FALLBACK_NAME)); .startWith(FALLBACK_NAME);
constructor( constructor(
public readonly apiUrl: ApiUrlConfig, public readonly apiUrl: ApiUrlConfig,

3
src/Squidex/app/shared/services/apps-store.service.ts

@ -74,7 +74,8 @@ export class AppsStoreService {
} }
private load() { private load() {
this.appsService.getApps().subscribe(apps => { this.appsService.getApps()
.subscribe(apps => {
this.apps$.next(apps); this.apps$.next(apps);
}); });
} }

3
src/Squidex/app/shell/pages/internal/profile-menu.component.ts

@ -43,7 +43,8 @@ export class ProfileMenuComponent implements OnInit, OnDestroy {
public ngOnInit() { public ngOnInit() {
this.authenticationSubscription = this.authenticationSubscription =
this.auth.isAuthenticated.take(1).subscribe(() => { this.auth.isAuthenticated.take(1)
.subscribe(() => {
const user = this.auth.user; const user = this.auth.user;
if (user) { if (user) {

3
src/Squidex/app/shell/pages/login/login-page.component.ts

@ -22,7 +22,8 @@ export class LoginPageComponent implements OnInit {
} }
public ngOnInit() { public ngOnInit() {
this.auth.loginRedirectComplete().subscribe( this.auth.loginRedirectComplete()
.subscribe(
() => { () => {
this.router.navigate(['/app'], { replaceUrl: true }); this.router.navigate(['/app'], { replaceUrl: true });
}, },

3
src/Squidex/app/shell/pages/logout/logout-page.component.ts

@ -22,7 +22,8 @@ export class LogoutPageComponent implements OnInit {
} }
public ngOnInit() { public ngOnInit() {
this.auth.logoutRedirectComplete().subscribe( this.auth.logoutRedirectComplete()
.subscribe(
() => { () => {
this.router.navigate(['/'], { replaceUrl: true }); this.router.navigate(['/'], { replaceUrl: true });
}, },

Loading…
Cancel
Save