Skip to content

Commit f8cbcdc

Browse files
authored
BC-11124 Add button to activate tool for all schools (#335)
1 parent a4652bf commit f8cbcdc

File tree

5 files changed

+53
-0
lines changed

5 files changed

+53
-0
lines changed

controllers/ctltools.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,13 @@ const getTableActions = (item, path) => {
185185
title: 'Datenblatt anzeigen',
186186
target: '_blank'
187187
},
188+
{
189+
link: path + 'add-and-activate-for-all-schools/' + item.id,
190+
class: 'btn-add-and-activate-tool-for-all-schools',
191+
icon: 'plus-square-o',
192+
title: 'für alle Schulen hinzufügen und aktivieren',
193+
isSimpleButton: true
194+
},
188195
{
189196
link: path + item.id,
190197
class: 'btn-delete',
@@ -377,6 +384,14 @@ const getMediumMedataHandler = (req, res) => {
377384
});
378385
}
379386

387+
const addAndActivateToolForAllSchools = (req, res, next) => {
388+
const toolId = req.params.id;
389+
390+
api(req, { version: 'v3' }).patch(`/tools/add-and-activate-for-all-schools/${toolId}`)
391+
.then(() => { res.redirect('/ctltools') })
392+
.catch(err => { next(err); });
393+
}
394+
380395
router.use(authHelper.authChecker);
381396

382397
router.get('/search', showTools);
@@ -386,6 +401,7 @@ router.get('/:id', getDetailHandler);
386401
router.delete('/:id', getDeleteHandler);
387402
router.post('/', getCreateHandler);
388403
router.get('/:id/datasheet', getDatasheet);
404+
router.patch('/add-and-activate-for-all-schools/:id', addAndActivateToolForAllSchools);
389405

390406
router.all('/', showTools);
391407

static/scripts/ctltools.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ $(document).ready(function () {
55
const $editModal = $('.edit-modal');
66
const $reglinkmodal = $('.reglink-modal');
77
const $deleteModal = $('.delete-modal');
8+
const $addAndActivateForAllSchoolsModal = $('.add-and-activate-for-all-schools-modal');
89
const $customParameterTemplate = $('#custom-parameter-template');
910
let customParameterId = 0;
1011

@@ -84,6 +85,25 @@ $(document).ready(function () {
8485
});
8586
});
8687

88+
$('.btn-add-and-activate-tool-for-all-schools').on('click', function (e) {
89+
e.preventDefault();
90+
91+
const currentRow = $(this).parents('tr');
92+
const toolId = currentRow.children().eq(0).text();
93+
const toolName = currentRow.children().eq(1).text();
94+
const action = `/ctltools/add-and-activate-for-all-schools/${toolId}`;
95+
96+
populateModalForm($addAndActivateForAllSchoolsModal, {
97+
action,
98+
title: 'Hinzufügen und aktivieren in allen Schulen',
99+
closeLabel: 'Abbrechen',
100+
submitLabel: 'Hinzufügen',
101+
fields: { name: toolName }
102+
});
103+
104+
$addAndActivateForAllSchoolsModal.modal('show');
105+
});
106+
87107
$('.parameters-regex').on('input', function (e) {
88108
const splitId = $(this).attr('id').split('-');
89109
const customIdIndex = splitId[splitId.length - 1];

views/ctltools/ctltools.hbs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,10 @@
6565
{{> "ctltools/forms/delete-form"}}
6666
{{/content}}
6767
{{/embed}}
68+
{{#embed "lib/components/modal-form" roles=roles method="patch" class="add-and-activate-for-all-schools-modal"}}
69+
{{#content "fields"}}
70+
{{> "ctltools/forms/add-and-activate-for-all-schools"}}
71+
{{/content}}
72+
{{/embed}}
6873
{{/content}}
6974
{{/extend}}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<div class="form-group">
2+
<fieldset disabled>
3+
<label class="control-label" for="name">
4+
Sind Sie sicher, dass Sie das folgende Tool in allen Schulen hinzufügen und aktivieren wollen?
5+
<input type="text" class="full-width" name="name" id="name">
6+
</label>
7+
</fieldset>
8+
</div>

views/lib/components/table.hbs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
<i class="fa fa-{{this.icon}}"></i> {{this.label}}
3939
</button>
4040
</form>
41+
{{else if this.isSimpleButton}}
42+
<button type="button" class="btn btn-secondary btn-sm {{this.class}}" title="{{this.title}}">
43+
<i class="fa fa-{{this.icon}}"></i> {{this.label}}
44+
</button>
4145
{{else}}
4246
<a class="btn btn-secondary btn-sm {{this.class}}" href="{{this.link}}" title="{{this.title}}" target="{{this.target}}">
4347
<i class="fa fa-{{this.icon}}"></i> {{this.label}}

0 commit comments

Comments
 (0)