Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make certain JGI columns always read-only in DataHarmonizer #1136

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion web/src/views/SubmissionPortal/HarmonizerView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ const TYPE_FIELD = ANALYSIS_TYPE;
// TODO: should this be derived from schema?
const COMMON_COLUMNS = [SAMP_NAME, SOURCE_MAT_ID, ANALYSIS_TYPE];

const ALWAYS_READ_ONLY_COLUMNS = [
'dna_seq_project',
'rna_seq_project',
'dna_samp_id',
'rna_samp_id',
'rna_seq_project_pi',
'dna_seq_project_pi',
'dna_project_contact',
'rna_project_contact',
'proposal_rna',
'proposal_dna',
'rna_seq_project_name',
'dna_seq_project_name',
];

// TODO: can this be imported from elsewhere?
const EMSL = 'emsl';
const JGI_MG = 'jgi_mg';
Expand Down Expand Up @@ -96,9 +111,10 @@ export default defineComponent({

watch(activeTemplate, () => {
harmonizerApi.loadData(activeTemplateData.value);
harmonizerApi.setColumnsReadOnly(ALWAYS_READ_ONLY_COLUMNS);
// if we're not on the first tab, the common columns should be read-only
if (activeTemplateKey.value !== templateList.value[0]) {
harmonizerApi.setColumnsReadOnly([0, 1, 2]);
harmonizerApi.setColumnsReadOnly(COMMON_COLUMNS);
harmonizerApi.setMaxRows(activeTemplateData.value.length);
}
});
Expand Down Expand Up @@ -1019,4 +1035,8 @@ html {
.sidebar-toggle-close {
transform: rotate(180deg);
}

.htDimmed {
cursor: not-allowed;
}
</style>
15 changes: 8 additions & 7 deletions web/src/views/SubmissionPortal/harmonizerApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,15 +414,16 @@ export class HarmonizerApi {
this._postTemplateChange();
}

setColumnsReadOnly(columns: number[]) {
setColumnsReadOnly(slotNames: string[]) {
const { hot } = this.dh;
const rowCount = hot.countRows();
columns.forEach((col) => {
for (let row = 0; row < rowCount; row += 1) {
hot.setCellMeta(row, col, 'readOnly', true);
const { columns } = hot.getSettings();
const fields = this.dh.getFields();
for (let col = 0; col < fields.length; col += 1) {
if (slotNames.includes(fields[col].name)) {
columns[col].readOnly = true;
}
});
hot.render();
}
hot.updateSettings({ columns });
}

setMaxRows(maxRows: number) {
Expand Down
Loading