Skip to content

Commit db9d01b

Browse files
committed
Merge branch 'remove-manifest' into dh2-i18n-rc1
2 parents f849a79 + ce66454 commit db9d01b

File tree

10 files changed

+303
-163
lines changed

10 files changed

+303
-163
lines changed

lib/AppContext.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ export default class AppContext {
266266
}
267267

268268
async initializeTemplate(template_path, options = {}) {
269-
const [template_name] = template_path.split('/');
270-
this.template = await Template.create(template_name, options);
269+
const [schema_folder] = template_path.split('/');
270+
this.template = await Template.create(schema_folder, options);
271271
return this;
272272
}
273273

lib/Toolbar.js

+19-14
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { MULTIVALUED_DELIMITER, titleOverText } from '../lib/utils/fields';
1919
import { takeKeys, invert } from '../lib/utils/objects';
2020
import {
2121
findBestLocaleMatch,
22-
templatePathForSchemaURI,
22+
// templatePathForSchemaURI,
2323
rangeToContainerClass,
2424
LocaleNotSupportedError,
2525
} from '../lib/utils/templates';
@@ -225,10 +225,13 @@ class Toolbar {
225225
// provided attempt to use that one. If not the first item in the menu
226226
// will be used.
227227
this.updateTemplateOptions();
228+
228229
if (options.templatePath) {
229-
const [folder, template] = options.templatePath.split('/');
230-
if (folder in this.menu && template in this.menu[folder]) {
231-
this.$selectTemplate.val(options.templatePath);
230+
const [schema_folder, template_name] = options.templatePath.split('/');
231+
for (const [schema_name, schema_obj] of Object.entries(this.menu)) {
232+
if ('folder' in schema_obj && schema_obj['folder'] == schema_folder && template_name in schema_obj['templates']) {
233+
this.$selectTemplate.val(options.templatePath);
234+
}
232235
}
233236
}
234237
this.loadSelectedTemplate();
@@ -309,14 +312,12 @@ class Toolbar {
309312

310313
updateTemplateOptions() {
311314
this.$selectTemplate.empty();
312-
//const view_drafts = $('#view-template-drafts').is(':checked');
313-
for (const [folder, templates] of Object.entries(this.menu)) {
314-
for (const [name, template] of Object.entries(templates)) {
315-
let path = folder + '/' + name;
316-
if (template.display) {
317-
// if (view_drafts || template.status == 'published') {
315+
for (const [schema_name, schema_obj] of Object.entries(this.menu)) {
316+
const templates = schema_obj['templates'];
317+
for (const [template_name, template_obj] of Object.entries(templates)) {
318+
let path = schema_obj.folder + '/' + template_name;
319+
if (template_obj.display) {
318320
this.$selectTemplate.append(new Option(path, path));
319-
// }
320321
}
321322
}
322323
}
@@ -363,6 +364,7 @@ class Toolbar {
363364
}
364365

365366
async openFile() {
367+
366368
const file = $('#open-file-input')[0].files[0];
367369
const ext = file.name.split('.').pop();
368370
const acceptedExts = ['xlsx', 'xls', 'tsv', 'csv', 'json'];
@@ -378,7 +380,7 @@ class Toolbar {
378380
// its Container class contains template spec itself.
379381
// It may have several dhs, one for each Container class mentioned.
380382
const contentBuffer = await readFileAsync(file);
381-
383+
//alert("opening " + file.name)
382384
let jsonData;
383385
try {
384386
jsonData = JSON.parse(contentBuffer.text);
@@ -465,7 +467,6 @@ class Toolbar {
465467
const baseName = $('#base-name-save-as-input').val();
466468
const ext = $('#file-ext-save-as-select').val();
467469
const lang = $('#select-translation-localization').val();
468-
469470
const MultiEntityJSON = Object.values(this.context.dhs).reduce(
470471
(acc, dh) => {
471472
return Object.assign(acc, { [dh.class_assignment]: dh.toJSON() });
@@ -480,8 +481,10 @@ class Toolbar {
480481
schema_container.attributes
481482
).reduce((acc, [cls_key, { name, range }]) => {
482483
// TODO: check if container attributes always have ranges?
483-
if (typeof range !== 'undefined') {
484+
if (typeof range !== 'undefined' && range == this.context.current_data_harmonizer_name) {
485+
//Or test range against this.context.appConfig.template_path.split('/')[1]
484486
const processedClass = {
487+
485488
[name]: MultiEntityJSON[range]
486489
.map((obj) => nullValuesToString(obj))
487490
.map((entry) => {
@@ -1066,10 +1069,12 @@ class Toolbar {
10661069
$('#section-menu').localize();
10671070
}
10681071

1072+
// NOT USED UNLESS LOADING FILE?
10691073
async _defaultGetSchema(schemaName) {
10701074
return this.menu[schemaName].schema;
10711075
}
10721076

1077+
// NOT USED UNLESS LOADING FILE?
10731078
async _defaultGetExportFormats(schemaName) {
10741079
return this.menu[schemaName].exportFormats;
10751080
}

0 commit comments

Comments
 (0)