Skip to content

Commit

Permalink
ui and ux changes
Browse files Browse the repository at this point in the history
  • Loading branch information
francescolf committed Oct 7, 2023
1 parent 825e2c6 commit 2417468
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 36 deletions.
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
<script src="/js/jquery.min.js"></script>
<script src="/js/darkmode.min.js"></script>
<script src="/js/bootstrap.bundle.min.js"></script>
</body>
</html>
6 changes: 3 additions & 3 deletions public/js/bootstrap.bundle.min.js

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions public/js/darkmode.min.js

This file was deleted.

4 changes: 0 additions & 4 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ const { loggedIn } = storeToRefs(store);
<header>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap-nightshade.min.css"
/>
</header>

<nav
Expand Down
12 changes: 0 additions & 12 deletions src/assets/styles/bootstrap-nightshade.min.css

This file was deleted.

6 changes: 6 additions & 0 deletions src/assets/styles/bootstrap.min.css

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/assets/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,9 @@

.small-logo {
height: 40px;
}

.tooltip-inner {
max-width: 250px!important;
width: 250px!important;;
}
10 changes: 9 additions & 1 deletion src/components/PermissionListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ library.add(faUser, faNewspaper, faTag, faXmark);
<div class="border rounded">
<div class="row">
<div class="col-8">
<h5 class="col ms-2 mt-1 text-truncate">
<h5 class="col ms-2 mt-1 text-truncate" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="a">
<i class="fas fa-user"></i>
<span v-if="!objectid">&nbsp; {{ grant }}</span>
<span v-else>
Expand All @@ -58,7 +58,15 @@ library.add(faUser, faNewspaper, faTag, faXmark);
</template>

<script>
import { getString } from "@/plugins/Translations.js"
export default {
mounted() {
var h5 = this.$el.querySelector("h5");
console.log(autofill[this.grant] ? autofill[this.grant][this.objectid] : null)
h5.setAttribute("data-bs-title", getString("permission_" + this.grant, autofill[this.grant] ? autofill[this.grant][this.objectid] : null));
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))
},
methods: {
remove() {
var btn = this.$el.querySelector("#btn-remove");
Expand Down
36 changes: 31 additions & 5 deletions src/components/barItems/DarkModeBarItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
import { usePolifemoStore } from "@/stores/polifemo";
export default {
data() {
return {
store: usePolifemoStore()
};
},
computed: {
darkMode: function () {
return localStorage.getItem("bs.prefers-color-scheme") === "dark";
Expand All @@ -18,25 +23,46 @@ export default {
mounted() {
this.updateIcon(this.darkMode);
this.loadDarkModePreference();
},
methods: {
toggleDarkMode() {
const store = usePolifemoStore();
darkmode.toggleDarkMode();
store.darkModeEnabled = !store.darkModeEnabled;
this.store.darkModeEnabled = !this.store.darkModeEnabled;
localStorage.setItem(
"bs.prefers-color-scheme",
this.store.darkModeEnabled ? "dark" : "light"
);
this.updateIcon();
this.applyDarkModePreference();
},
updateIcon(force) {
const store = usePolifemoStore();
if (store.darkModeEnabled || force) {
if (this.store.darkModeEnabled || force) {
document.getElementById("darkmode-icon").classList.remove("fa-moon");
document.getElementById("darkmode-icon").classList.add("fa-sun");
} else {
document.getElementById("darkmode-icon").classList.remove("fa-sun");
document.getElementById("darkmode-icon").classList.add("fa-moon");
}
},
loadDarkModePreference() {
// The dark mode preference might not be set, so we need to check it
if (localStorage.getItem("bs.prefers-color-scheme") === null) {
localStorage.setItem("bs.prefers-color-scheme", "light");
}
this.store.darkModeEnabled =
localStorage.getItem("bs.prefers-color-scheme") === "dark";
this.applyDarkModePreference();
},
applyDarkModePreference() {
if (this.store.darkModeEnabled) {
document.documentElement.setAttribute("data-bs-theme", "dark");
} else {
document.documentElement.removeAttribute("data-bs-theme");
}
}
}
};
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/Translations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import strings from "@/stores/strings.json";
export const getString = (key, ...args) => {
var str = strings[key];
for (var i = 0; i < args.length; i++) {
str = str.replace("%" + (i+1), args[i]);
}
return str;
}
9 changes: 9 additions & 0 deletions src/stores/strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"permission_permissions": "Può aggiungere e rimuovere permessi agli utenti",
"permission_authors": "Può pubblicare e eliminare articoli per conto di %1",
"tags_altro": "Altro",
"tags_studenti": "Studenti",
"tags_polimiworld": "Polimiworld",
"tags_ateneo": "Ateneo",
"tags_ricerca": "Ricerca e innovazione"
}
5 changes: 2 additions & 3 deletions src/views/ArticlesView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ import axios from "axios";
import Cherry from "cherry-markdown/dist/cherry-markdown.core";
import { API_BASE_URL, checkPagePermission } from "@/plugins/AuthUtils";
import { showToast } from "@/plugins/ToastManager";
import { getString } from "@/plugins/Translations.js"
import ArticlesSearchForm from "@/components/ArticlesSearchForm.vue";
library.add(
Expand Down Expand Up @@ -388,10 +389,8 @@ export default {
.get(API_BASE_URL + "/tags")
.then((response) => {
response.data.tags.forEach((cat) => {
var catname =
cat.name.charAt(0).toUpperCase() + cat.name.slice(1).toLowerCase();
$("#selectcategoria").append(
'<option value="' + cat.name + '">' + catname + "</option>"
'<option value="' + cat.name + '">' + getString(cat.name) + "</option>"
);
});
})
Expand Down
1 change: 1 addition & 0 deletions src/views/PermissionsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export default {
methods: {
getPermissionsOfUser() {
this.tempPermList = [];
$("#permissions-loading").removeClass("d-none");
axios
.get(
Expand Down
2 changes: 1 addition & 1 deletion src/views/WelcomeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

<style>
@import "@/assets/styles/main.css";
@import "@/assets/styles/bootstrap-nightshade.min.css";
@import "@/assets/styles/bootstrap.min.css";
</style>

<script>
Expand Down

0 comments on commit 2417468

Please sign in to comment.