Skip to content

Commit

Permalink
N21-2019 show tool usage (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorCapCoder authored Jul 5, 2024
1 parent cc85ceb commit bb37c71
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ data:
FEATURE_SCHOOL_SANIS_USER_MIGRATION_ENABLED: "{{ FEATURE_SCHOOL_SANIS_USER_MIGRATION_ENABLED|default(false, true) }}"
FEATURE_SHOW_OUTDATED_USERS: "{{ FEATURE_SHOW_OUTDATED_USERS|default(false, true) }}"
FEATURE_ENABLE_LDAP_SYNC_DURING_MIGRATION: "{{ FEATURE_ENABLE_LDAP_SYNC_DURING_MIGRATION|default(false, true) }}"
FEATURE_MEDIA_SHELF_ENABLED: "{{ FEATURE_MEDIA_SHELF_ENABLED|default(false, true) }}"
9 changes: 9 additions & 0 deletions controllers/ctltools.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ const router = express.Router();
const authHelper = require('../helpers/authentication');
const { api } = require('../api');
const moment = require('moment');
const {isFeatureFlagTrue} = require("../helpers/featureFlagHelper");
moment.locale('de');

const MEDIA_SHELF_ENABLED = isFeatureFlagTrue(process.env.FEATURE_MEDIA_SHELF_ENABLED)

const clearEmptyInputs = (object) => {
Object.keys(object).forEach((key) => {
const type = typeof object[key];
Expand Down Expand Up @@ -94,8 +97,14 @@ const getDetailHandler = (req, res, next) => {
toolData.config.redirectUris = toolData.config.redirectUris.join(';');
}

const showMediaShelfCount = !MEDIA_SHELF_ENABLED && toolMetaData.contextExternalToolCountPerContext.mediaBoard === 0;
if (showMediaShelfCount) {
delete toolMetaData.contextExternalToolCountPerContext.mediaBoard;
}

convertZerosToString(toolMetaData);
res.json({...toolData, ...toolMetaData});

}).catch(err => {
next(err);
});
Expand Down
6 changes: 6 additions & 0 deletions static/scripts/ctltools.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ $(document).ready(function () {
e.preventDefault();
var entry = $(this).parent().attr('action');
$.getJSON(entry, function (result) {
if (!result.contextExternalToolCountPerContext.mediaBoard) {
$('#media-board-label').hide();
} else {
$('#media-board-label').show();
}

populateModalForm($deleteModal, {
action: entry,
title: 'Tool wirklich löschen?',
Expand Down
5 changes: 5 additions & 0 deletions views/ctltools/forms/delete-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
<input type="text" class="number-input-field" name="contextExternalToolCountPerContext[boardElement]" id="board">
Spalten-Board(s)
</label>
<br>
<label class="control-label" for="media-board" id="media-board-label">
<input type="text" class="number-input-field" name="contextExternalToolCountPerContext[mediaBoard]" id="media-board">
Medienregal(e)
</label>
</fieldset>

<label class="control-label">
Expand Down

0 comments on commit bb37c71

Please sign in to comment.