Skip to content

hasDirtyAttributes: true right after findAll #167

@michDostal

Description

@michDostal

Hello I have problem with loading data, right after I load them from backend, entity has hasDirtyAttributes:true and on save its sending complete entity back to backend instead of only changed fields. happens for findAll() and find()

screenshot_7
list.component.ts

ngOnInit() {
this.clients = this.route.snapshot.data['clients'].getModels();
}

client.resolve.ts

export class ClientsResolve implements Resolve<any> {
  constructor(private datastore: ClientDatastore) {
  }

  resolve(route: ActivatedRouteSnapshot): Observable<any> | Promise<any> | any {

    let include = '';
    if (route.data.include) {
      include += route.data.include;
    }
    return this.datastore.findAll(Client, {
      include: include
    });
  }
}

client.routes.ts

{
    path: 'list',
    component: ClientListComponent,
    data: {
      breadcrumb: 'Přehled',
      include: 'advisor'
    },
    resolve: {
      clients: ClientsResolve
    }
  },

client.datastore.ts

const config: DatastoreConfig = {
  baseUrl: environment.apiURL + '/v2',
  models: {
    client: Client,
    advisors: Advisor,
    goals: Goal
  }
};

@Injectable()
@JsonApiDatastoreConfig(config)
export class ClientDatastore extends JsonApiDatastore {
  constructor(http: Http) {
    super(http);
    this.headers = new Headers({'Authorization': 'Bearer ' + localStorage.getItem('token')});
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions