From 1d6834302d83120fbe07f4f4bfb8822c82364091 Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Thu, 5 Oct 2023 14:11:17 +0200
Subject: [PATCH] Change js structure for displays
---
.../corpus-display.js} | 2 +-
.../ResourceDisplay.js => resource-displays/index.js} | 6 ++++--
.../JobDisplay.js => resource-displays/job-display.js} | 2 +-
app/templates/_scripts.html.j2 | 8 ++++----
app/templates/corpora/corpus.html.j2 | 2 +-
app/templates/jobs/job.html.j2 | 2 +-
6 files changed, 12 insertions(+), 10 deletions(-)
rename app/static/js/{ResourceDisplays/CorpusDisplay.js => resource-displays/corpus-display.js} (97%)
rename app/static/js/{ResourceDisplays/ResourceDisplay.js => resource-displays/index.js} (92%)
rename app/static/js/{ResourceDisplays/JobDisplay.js => resource-displays/job-display.js} (97%)
diff --git a/app/static/js/ResourceDisplays/CorpusDisplay.js b/app/static/js/resource-displays/corpus-display.js
similarity index 97%
rename from app/static/js/ResourceDisplays/CorpusDisplay.js
rename to app/static/js/resource-displays/corpus-display.js
index 29e8b205..6bfa1676 100644
--- a/app/static/js/ResourceDisplays/CorpusDisplay.js
+++ b/app/static/js/resource-displays/corpus-display.js
@@ -1,4 +1,4 @@
-class CorpusDisplay extends ResourceDisplay {
+ResourceDisplays.CorpusDisplay = class CorpusDisplay extends ResourceDisplays.BaseDisplay {
constructor(displayElement) {
super(displayElement);
this.corpusId = displayElement.dataset.corpusId;
diff --git a/app/static/js/ResourceDisplays/ResourceDisplay.js b/app/static/js/resource-displays/index.js
similarity index 92%
rename from app/static/js/ResourceDisplays/ResourceDisplay.js
rename to app/static/js/resource-displays/index.js
index 24a5dec3..75c68987 100644
--- a/app/static/js/ResourceDisplays/ResourceDisplay.js
+++ b/app/static/js/resource-displays/index.js
@@ -1,4 +1,6 @@
-class ResourceDisplay {
+var ResourceDisplays = {};
+
+ResourceDisplays.BaseDisplay = class BaseDisplay {
constructor(displayElement) {
this.displayElement = displayElement;
this.userId = this.displayElement.dataset.userId;
@@ -41,4 +43,4 @@ class ResourceDisplay {
this.setElement(element, value);
}
}
-}
+};
diff --git a/app/static/js/ResourceDisplays/JobDisplay.js b/app/static/js/resource-displays/job-display.js
similarity index 97%
rename from app/static/js/ResourceDisplays/JobDisplay.js
rename to app/static/js/resource-displays/job-display.js
index 6287d934..2d107716 100644
--- a/app/static/js/ResourceDisplays/JobDisplay.js
+++ b/app/static/js/resource-displays/job-display.js
@@ -1,4 +1,4 @@
-class JobDisplay extends ResourceDisplay {
+ResourceDisplays.JobDisplay = class JobDisplay extends ResourceDisplays.BaseDisplay {
constructor(displayElement) {
super(displayElement);
this.jobId = this.displayElement.dataset.jobId;
diff --git a/app/templates/_scripts.html.j2 b/app/templates/_scripts.html.j2
index 7ebb61c2..b2ca56a4 100644
--- a/app/templates/_scripts.html.j2
+++ b/app/templates/_scripts.html.j2
@@ -45,10 +45,10 @@
{%- assets
filters='rjsmin',
- output='gen/ResourceDisplays.%(version)s.js',
- 'js/ResourceDisplays/ResourceDisplay.js',
- 'js/ResourceDisplays/CorpusDisplay.js',
- 'js/ResourceDisplays/JobDisplay.js'
+ output='gen/resource-displays.%(version)s.js',
+ 'js/resource-displays/index.js',
+ 'js/resource-displays/corpus-display.js',
+ 'js/resource-displays/job-display.js'
%}
{%- endassets %}
diff --git a/app/templates/corpora/corpus.html.j2 b/app/templates/corpora/corpus.html.j2
index 21a10221..7539f420 100644
--- a/app/templates/corpora/corpus.html.j2
+++ b/app/templates/corpora/corpus.html.j2
@@ -237,7 +237,7 @@
{% block scripts %}
{{ super() }}