Skip to content

Commit 195bf9a

Browse files
authored
Merge pull request #596 from CruGlobal/resourceTranslations
Reduce translations data loaded from the API
2 parents b3ff02f + 0f91832 commit 195bf9a

File tree

7 files changed

+4
-17
lines changed

7 files changed

+4
-17
lines changed

src/app/components/multiple-draft-generator/multiple-draft-generator.component.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ describe('MultipleDraftGeneratorComponent', () => {
5252

5353
const r = new Resource();
5454
r['latest-drafts-translations'] = translations;
55-
r.translations = translations;
5655
comp.resource = r;
5756

5857
fixture.detectChanges();

src/app/components/multiple-draft-generator/multiple-draft-generator.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class MultipleDraftGeneratorComponent {
2525
) {}
2626

2727
showConfirmAlert(): void {
28-
this.translations = this.resource.translations.filter(
28+
this.translations = this.resource['latest-drafts-translations'].filter(
2929
(translation) => translation.generateDraft,
3030
);
3131
if (this.translations.length === 0) {

src/app/components/resources/resources.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('ResourcesComponent', () => {
6262

6363
setTimeout(() => {
6464
expect(resourceServiceStub.getResources).toHaveBeenCalledWith(
65-
'translations,pages,custom-manifests,tips,attachments,variants',
65+
'latest-drafts-translations,pages,custom-manifests,tips,attachments,variants',
6666
);
6767

6868
done();

src/app/components/resources/resources.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class ResourcesComponent implements OnInit {
3535

3636
this.resourceService
3737
.getResources(
38-
'translations,pages,custom-manifests,tips,attachments,variants',
38+
'latest-drafts-translations,pages,custom-manifests,tips,attachments,variants',
3939
)
4040
.then((resources) => {
4141
this.resources = resources;

src/app/components/translation/translation.component.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ describe('TranslationComponent', () => {
163163
translation.language = language;
164164
translation.resource = comp.resource;
165165

166-
comp.resource.translations = [translation];
167166
comp.resource['latest-drafts-translations'] = [translation];
168167
comp.reloadTranslation();
169168
fixture.detectChanges();

src/app/models/resource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class Resource {
1919
metatool?: Resource;
2020
variants: Resource[];
2121
'default-variant'?: Resource;
22-
translations: Translation[];
22+
'latest-drafts-translations': Translation[];
2323
attachments: Attachment[];
2424
pages: Page[];
2525
tips: Tip[];

src/app/service/resource/resource.service.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,6 @@ export class ResourceService extends AbstractService {
2727
.catch(this.handleError);
2828
}
2929

30-
getResource(id: number, include: string): Promise<Resource> {
31-
const url = `${this.resourcesUrl}/${id}?include=${include}`;
32-
return this.http
33-
.get(url)
34-
.toPromise()
35-
.then(function (response) {
36-
return new JsonApiDataStore().sync(response.json());
37-
})
38-
.catch(this.handleError);
39-
}
40-
4130
create(resource: Resource): Promise<Resource> {
4231
return this.http
4332
.post(

0 commit comments

Comments
 (0)