Verified Commit d1c90ce6 by Luc Didry Committed by Luc Didry

Fix #100 Allow to migrate some pads to other folder

This commit is dedicated to Schoumi, who is supporting me on Tipeee.
Many thanks :-)
parent aec16267
Pipeline #50985 passed with stage
in 1 minute 11 seconds
......@@ -66,6 +66,7 @@ module.exports = (function () {
return (isAdmin && (g._id !== gid));
})
.value();
c.noSelectedPads = m.prop(false);
c.group = model.groups()[gid];
};
......@@ -83,7 +84,7 @@ module.exports = (function () {
e.preventDefault();
var _pads = ld.clone(model.pads(), true);
var pads = ld.reduce(model.pads(), function (memo, p, k) {
if (p.group === gid) {
if (p.group === gid && document.querySelectorAll('input.pad-to-move[name="'+p._id+'"]:checked').length > 0) {
p.group = c.data.newGroup();
_pads[k] = p;
memo.push(p);
......@@ -158,6 +159,27 @@ module.exports = (function () {
return { label: label, icon: icon, select: select };
};
view.pads = function (c) {
var pads = [];
var gid = m.route.param('group');
ld.forEach(model.pads(), function(p) {
if (p.group === gid) {
pads.push(m('.checkbox', [
m('label', [
m('input.pad-to-move[type="checkbox"]', {
name: p._id, checked: 'checked',
onchange: function() {
c.noSelectedPads(document.querySelectorAll('input.pad-to-move:checked').length === 0);
}
}),
p.name
])
]));
}
});
return pads;
};
/**
* ### form
*
......@@ -166,17 +188,48 @@ module.exports = (function () {
view.form = function (c) {
var vg = view.groups(c);
var vp = view.pads(c);
var elements = [ m('.form-group', [
vg.label, vg.icon,
m('.col-sm-7', vg.select)
])
];
if (c.selectedGroups.length > 0) {
elements.push(m('input.btn.btn-success.pull-right', {
form: 'padmove-form',
type: 'submit',
value: conf.LANG.ACTIONS.SAVE
}));
elements.push([
m('div', [
m('button.btn.btn-info.btn-sm', {
onclick: function(e) {
e.preventDefault();
var pads = document.querySelectorAll('input.pad-to-move');
[].forEach.call(pads, function(element) {
element.checked = true;
});
c.noSelectedPads(false);
},
}, conf.LANG.GROUP.PAD.SELECT_ALL),
m('span', ' '),
m('button.btn.btn-info.btn-sm', {
onclick: function(e) {
e.preventDefault();
var pads = document.querySelectorAll('input.pad-to-move');
[].forEach.call(pads, function(element) {
element.checked = false;
});
c.noSelectedPads(true);
},
}, conf.LANG.GROUP.PAD.DESELECT_ALL),
]),
m('div', {
class: (c.noSelectedPads()) ? 'h3' : 'hidden'
}, [ m('b', conf.LANG.GROUP.PAD.SELECT_AT_LEAST_ONE_PAD) ]),
vp,
m('input.btn.btn-success.pull-right', {
form: 'padmove-form',
type: 'submit',
disabled: c.noSelectedPads(),
value: conf.LANG.ACTIONS.SAVE
})
]);
}
return m('form.form-horizontal', {
id: 'padmove-form',
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -256,6 +256,7 @@
"ADD": "Erstelle ein neues Pad",
"ADD_PROMPT": "Titel des neuen Pads",
"ADMINS": "Admins",
"DESELECT_ALL": "Deselect all pads",
"EDIT": "Bearbeite das Pad",
"EDIT_PROMPT": "Neuer Name des Pads",
"EXPAND": "Erweitern",
......@@ -269,6 +270,8 @@
"PADS": "Pads",
"PUBLIC_DENIED": "Öffentlicher Zugang: Sie dürfen diese Daten nicht einsehen.",
"REDUCE": "Reduzieren",
"SELECT_ALL": "Select all pads",
"SELECT_AT_LEAST_ONE_PAD": "Please, select at least one pad",
"SORT_BY": "Sortiere die Pads nach",
"SORT_BY_CREATION": "Erstellungdatum",
"SORT_BY_NAME": "Name",
......
......@@ -256,6 +256,7 @@
"ADD": "Create a new pad",
"ADD_PROMPT": "Enter the name of the new pad",
"ADMINS": "Admins",
"DESELECT_ALL": "Deselect all pads",
"EDIT": "Edit a pad",
"EDIT_PROMPT": "Enter the new name of the pad",
"EXPAND": "Expand",
......@@ -269,6 +270,8 @@
"PADS": "Pads",
"PUBLIC_DENIED": "Public access: you are not allowed to see this data.",
"REDUCE": "Reduce",
"SELECT_ALL": "Select all pads",
"SELECT_AT_LEAST_ONE_PAD": "Please, select at least one pad",
"SORT_BY": "Sort pads by",
"SORT_BY_CREATION": "creation date",
"SORT_BY_NAME": "name",
......
......@@ -256,6 +256,7 @@
"ADD": "Crear un nuevo pad",
"ADD_PROMPT": "Introduzca el nombre del nuevo pad",
"ADMINS": "Adminstradoras",
"DESELECT_ALL": "Deselect all pads",
"EDIT": "Editar un pad",
"EDIT_PROMPT": "Introduzca el nuevo nombre del pad",
"EXPAND": "Expender ",
......@@ -269,6 +270,8 @@
"PADS": "Pads",
"PUBLIC_DENIED": "Acceso público: no está permitida ver estos datos.",
"REDUCE": "Reducir",
"SELECT_ALL": "Select all pads",
"SELECT_AT_LEAST_ONE_PAD": "Please, select at least one pad",
"SORT_BY": "Ordenar los pads por",
"SORT_BY_CREATION": "fecha de creación",
"SORT_BY_NAME": "nombre",
......
......@@ -256,6 +256,7 @@
"ADD": "Créer un nouveau pad",
"ADD_PROMPT": "Saisissez le nom du nouveau pad",
"ADMINS": "Administrateurs",
"DESELECT_ALL": "Déselectionner tous les pads",
"EDIT": "Modifier un pad",
"EDIT_PROMPT": "Saisissez le nouveau nom du pad",
"EXPAND": "Agrandir",
......@@ -269,6 +270,8 @@
"PADS": "Pads",
"PUBLIC_DENIED": "Accès public : vous n’êtes pas autorisé à voir ces données.",
"REDUCE": "Réduire",
"SELECT_ALL": "Sélectionner tous les pads",
"SELECT_AT_LEAST_ONE_PAD": "Veuillez sélectionner au moins un pad",
"SORT_BY": "Ranger les pads par",
"SORT_BY_CREATION": "date de création",
"SORT_BY_NAME": "nom",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment