|
@@ -1,7 +1,9 @@
|
|
import { BaseView } from "./base-view";
|
|
import { BaseView } from "./base-view";
|
|
import { PouchService } from "../services/pouch-service";
|
|
import { PouchService } from "../services/pouch-service";
|
|
|
|
|
|
-import { EventsManager } from "../base/events/event-manager";
|
|
|
|
|
|
+import { Observable } from "rxjs/Observable";
|
|
|
|
+import "rxjs/add/observable/from";
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
@@ -119,19 +121,52 @@ export abstract class BaseDetailsView<T> extends BaseView<T> {
|
|
this.setItem(Object.create(null));
|
|
this.setItem(Object.create(null));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ saveRelated(): Observable<any> {
|
|
|
|
+ let fields: Array<any> = super.getFieldsRelated();
|
|
|
|
+
|
|
|
|
+ if (fields.length > 0) {
|
|
|
|
+ let field: any = null;
|
|
|
|
+
|
|
|
|
+ // for (let i = 0; i < fields.length; i++) {
|
|
|
|
+ // field = fields[i];
|
|
|
|
+
|
|
|
|
+ // if (field.options.type === "one2many") {
|
|
|
|
+ // this.saveOneToMany(field.fieldName);
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ return Observable.from(fields);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Observable.empty();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ saveOneToMany(fieldName: string): void {
|
|
|
|
+ console.log(fieldName);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
* @param data
|
|
* @param data
|
|
*/
|
|
*/
|
|
performSave(): void {
|
|
performSave(): void {
|
|
this.setItem(Object.assign(this.getItem(), { odoo_model: super.getModelName(), odoo_status: this.getAction() }));
|
|
this.setItem(Object.assign(this.getItem(), { odoo_model: super.getModelName(), odoo_status: this.getAction() }));
|
|
- super.getInjectable(PouchService).save(this.getItem()).subscribe(result => {
|
|
|
|
- EventsManager.publish("app:changed", {
|
|
|
|
- action: this.getAction() === "to_create" ? "add" : "update",
|
|
|
|
- item: Object.assign(this.getItem(), { _id: result.id, _rev: result.rev })
|
|
|
|
- });
|
|
|
|
- }, error => {
|
|
|
|
- EventsManager.publish("app:error", error);
|
|
|
|
- });
|
|
|
|
|
|
+ this.saveRelated();
|
|
|
|
+ // super.getInjectable(PouchService).save(this.getItem()).subscribe(result => {
|
|
|
|
+ // EventsManager.publish("app:changed", {
|
|
|
|
+ // action: this.getAction() === "to_create" ? "add" : "update",
|
|
|
|
+ // item: Object.assign(this.getItem(), { _id: result.id, _rev: result.rev })
|
|
|
|
+ // });
|
|
|
|
+ // }, error => {
|
|
|
|
+ // EventsManager.publish("app:error", error);
|
|
|
|
+ // });
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|