Skip to content

Commit

Permalink
Merge branch 'hypernext' into js
Browse files Browse the repository at this point in the history
* hypernext:
  3.5.5
  add autocomplete='off' for show mode checkboxes. fix #2185
  composer upgrade
  Fixed image edit bug with tinymce ImageTools (#2197)
  fix next step display not following ordering
  don't restrict events to the team for an item
  fix permissions on database items in some cases
  yarn upgrade
  Fix unfinished steps sorting in todo list (#2169)
  add referal link and plant more trees badge
  add carbon offset and trees badges to README
  fix unselectable single column layout option in ucp. fix #2167
  • Loading branch information
NicolasCARPi committed Sep 28, 2020
2 parents 11455cd + a6b8aa7 commit 6e5969c
Show file tree
Hide file tree
Showing 30 changed files with 547 additions and 586 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
[![License](https://img.shields.io/badge/license-AGPL-blue.svg)](https://www.gnu.org/licenses/agpl-3.0.en.html)
[![Release](https://img.shields.io/github/release/elabftw/elabftw.svg)](https://github.com/elabftw/elabftw/releases/latest)
[![StackShare](https://img.shields.io/badge/tech-stack-0690fa.svg?style=flat)](https://stackshare.io/elabftw/elabftw)
[![Joss](http://joss.theoj.org/papers/10.21105/joss.00146/status.svg)](http://joss.theoj.org/papers/10.21105/joss.00146)
[![Joss](http://joss.theoj.org/papers/10.21105/joss.00146/status.svg)](http://joss.theoj.org/papers/10.21105/joss.00146)<br>
[![Carbon offset](https://img.shields.io/ecologi/carbon/deltablot)](https://ecologi.com/deltablot)
[![Trees](https://img.shields.io/ecologi/trees/deltablot)](https://ecologi.com/deltablot)
[![Plant more](https://img.shields.io/badge/trees-plant%20more%20trees-brightgreen)](https://ecologi.com/?r=5f668f69232cc100192fbd04)

# Description

Expand Down
180 changes: 115 additions & 65 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/classes/ReleaseCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class ReleaseCheck
{
/** @var string INSTALLED_VERSION the current version of elabftw */
public const INSTALLED_VERSION = '3.5.4';
public const INSTALLED_VERSION = '3.5.5';

/** @var string $URL this file contains the latest version information */
private const URL = 'https://get.elabftw.net/updates.ini';
Expand Down
3 changes: 3 additions & 0 deletions src/langs/js-strings.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
// please-wait
_('Please wait…');
/** @psalm-suppress UnusedFunctionCall */
// replace-edited-file
_('Do you want to replace the file on the server with this edit?');
/** @psalm-suppress UnusedFunctionCall */
// request-filename
_('Enter name of the file');
/** @psalm-suppress UnusedFunctionCall */
Expand Down
2 changes: 1 addition & 1 deletion src/maps/UserPreferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public function hydrate(array $source): void
$this->setDisplaySize($source['display_size'] ?? $this->displaySize);
$this->setSort($source['sort'] ?? $this->sort);
$this->setOrderby($source['orderby'] ?? $this->orderby);
$this->setSingleColumnLayout($source['single_column_layout'] ?? (string) $this->singleColumnLayout);
$this->setSingleColumnLayout($source['single_column_layout'] ?? '0');
$this->setShortcut('create', $source['sc_create'] ?? $this->shortcuts['create']);
$this->setShortcut('edit', $source['sc_edit'] ?? $this->shortcuts['edit']);
$this->setShortcut('submit', $source['sc_submit'] ?? $this->shortcuts['submit']);
Expand Down
10 changes: 8 additions & 2 deletions src/models/AbstractEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,14 @@ public function readShow(DisplayParams $displayParams, bool $extended = false):
foreach ($this->filters as $filter) {
$sql .= sprintf(" AND %s = '%s'", $filter['column'], $filter['value']);
}
// teamFilter is to restrict to the team for items only
// as they have a team column
$teamFilter = '';
if ($this instanceof Database) {
$teamFilter = ' AND users2teams.teams_id = entity.team';
}
// add pub/org/team filter
$sql .= " AND ( entity.canread = 'public' OR entity.canread = 'organization' OR (entity.canread = 'team' AND users2teams.users_id = entity.userid) OR (entity.canread = 'user' ";
$sql .= " AND ( entity.canread = 'public' OR entity.canread = 'organization' OR (entity.canread = 'team' AND users2teams.users_id = entity.userid" . $teamFilter . ") OR (entity.canread = 'user' ";
// admin will see the experiments with visibility user for user of their team
if ($this->Users->userData['is_admin']) {
$sql .= 'AND entity.userid = users2teams.users_id)';
Expand Down Expand Up @@ -620,7 +626,7 @@ private function getReadSqlBeforeWhere(bool $getTags = true, bool $fullSelect =
entity.lastchange,';
}
$select .= "uploads.up_item_id, uploads.has_attachment,
SUBSTRING_INDEX(GROUP_CONCAT(stepst.next_step SEPARATOR '|'), '|', 1) AS next_step,
SUBSTRING_INDEX(GROUP_CONCAT(stepst.next_step ORDER BY ordering SEPARATOR '|'), '|', 1) AS next_step,
categoryt.id AS category_id,
categoryt.name AS category,
categoryt.color,
Expand Down
3 changes: 1 addition & 2 deletions src/models/Scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,9 @@ public function read(string $start, string $end): array
LEFT JOIN experiments ON (experiments.id = team_events.experiment)
LEFT JOIN items_types ON items.category = items_types.id
LEFT JOIN users AS u ON team_events.userid = u.userid
WHERE team_events.team = :team AND team_events.item = :item
WHERE team_events.item = :item
AND team_events.start > :start AND team_events.end < :end";
$req = $this->Db->prepare($sql);
$req->bindParam(':team', $this->Database->Users->userData['team'], PDO::PARAM_INT);
$req->bindParam(':item', $this->Database->id, PDO::PARAM_INT);
$req->bindParam(':start', $start);
$req->bindParam(':end', $end);
Expand Down
13 changes: 10 additions & 3 deletions src/models/Steps.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ public function readAll(): array
FROM experiments
CROSS JOIN (
SELECT item_id, finished,
GROUP_CONCAT(experiments_steps.body SEPARATOR '|') AS steps_body,
GROUP_CONCAT(experiments_steps.id SEPARATOR '|') AS steps_id
GROUP_CONCAT(experiments_steps.body ORDER BY experiments_steps.ordering SEPARATOR '|') AS steps_body,
GROUP_CONCAT(experiments_steps.id ORDER BY experiments_steps.ordering SEPARATOR '|') AS steps_id
FROM experiments_steps
WHERE finished = 0 GROUP BY item_id) AS stepst ON (stepst.item_id = experiments.id)
WHERE userid = :userid GROUP BY experiments.id ORDER BY experiments.id DESC";
Expand All @@ -155,7 +155,14 @@ public function readAll(): array
// clean up the results so we get a nice array with experiment id/title and steps with their id/body
// use reference to edit in place
foreach ($res as &$exp) {
$exp['steps'] = array_combine(explode('|', $exp['steps_id']), explode('|', $exp['steps_body']));
$stepIDs = explode('|', $exp['steps_id']);
$stepsBodies = explode('|', $exp['steps_body']);

$expSteps = array();
foreach ($stepIDs as $key => $stepID) {
$expSteps[] = array($stepID, $stepsBodies[$key]);
}
$exp['steps'] = $expSteps;
unset($exp['steps_body'], $exp['steps_id'], $exp['finished']);
}

Expand Down
2 changes: 1 addition & 1 deletion src/templates/show-item.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

<p class='item-info'>
<!-- checkbox -->
<input class='item-checkbox' type='checkbox' data-id='{{ item.id }}' data-randomid='{{ randomId }}' data-type='{{ Entity.type }}' aria-label='Select' style='width:15px;vertical-align:-3px;' />
<input class='item-checkbox' autocomplete='off' type='checkbox' data-id='{{ item.id }}' data-randomid='{{ randomId }}' data-type='{{ Entity.type }}' aria-label='Select' style='width:15px;vertical-align:-3px;' />
<!-- edit icon -->
{% if not item.locked and (item.userid == App.Users.userData.userid or Entity.type == 'items' or App.Session.get('is_admin')) %}
<a href='{{ Entity.page }}.php?mode=edit&id={{ item.id }}'><i class='fas fa-pencil-alt clickable link-like'></i></a>
Expand Down
4 changes: 3 additions & 1 deletion src/ts/Todolist.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ export default class Todolist extends Crud {
let html = '';
for (const exp of json.msg) {
html += `<li><h3><a href='experiments.php?mode=view&id=${exp.id}'>${exp.title}</a></h3>`;
for (const [stepId, stepBody] of Object.entries(exp.steps)) {
for (const stepsData of Object.entries(exp.steps)) {
const stepId = stepsData[1][0];
const stepBody = stepsData[1][1];
html += `<div><input type='checkbox' class='stepbox mr-1' id='todo_step_${stepId}' data-id='${exp.id}' data-type='experiments' data-stepid='${stepId}' />${stepBody}</div>`;
}
html += '</li>';
Expand Down
67 changes: 64 additions & 3 deletions src/ts/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ $(document).ready(function() {
StarC.update($(this).data('rating').current[0].innerText);
});

// Object to hold control data for selected image
let tinymceEditImage = {selected:false, uploadId:'', itemId:'', url:''};

/* eslint-disable */
tinymce.init({
mode: 'specific_textareas',
Expand All @@ -395,10 +398,40 @@ $(document).ready(function() {
paste_data_images: true,
images_upload_handler: function (blobInfo, success, failure) {
let dropZone = Dropzone.forElement('#elabftw-dropzone');
// Edgecase for editing an image using tinymce ImageTools
// Check if it was selected. This is set by an event hook below
if (tinymceEditImage.selected == true && confirm(i18next.t('replace-edited-file'))){
// Use jquery to replace the file on the server
const formData = new FormData();
formData.append('replace', 'true');
formData.append('upload_id', tinymceEditImage.uploadId);
formData.append('id', tinymceEditImage.itemId);
formData.append('type', 'experiments');
formData.append('file', blobInfo.blob());

$.post({
url: 'app/controllers/EntityAjaxController.php',
data: formData,
processData: false,
contentType: false
}).done(function(json){
notif(json);
// Send the same url we stored before the edit menu was clicked to tinymce
success(tinymceEditImage.url);
tinymceEditImage = {selected:false, uploadId:'', itemId:'', url:''};
}
);
}
// If the blob has no filename, ask for one. (Firefox edgecase: Embedded image in Data URL)
if (typeof blobInfo.blob().name=== 'undefined'){
let fileOfBlob = new File([blobInfo.blob()], prompt('Enter filename with extension e.g. .jpeg'));
dropZone.addFile(fileOfBlob);
else if (typeof blobInfo.blob().name=== 'undefined'){
let fname = prompt('Enter filename with extension e.g. .jpeg');
if (typeof fname !== 'undefined' && fname !== null)
{
let fileOfBlob = new File([blobInfo.blob()], fname);
dropZone.addFile(fileOfBlob);
dropZone.tinyImageSuccess = success;
}
else {tinymce.activeEditor.undoManager.undo();} // Just disregard the edit if the name prompt is cancelled
} else {
dropZone.addFile(blobInfo.blob());
dropZone.tinyImageSuccess = success;
Expand Down Expand Up @@ -493,6 +526,34 @@ $(document).ready(function() {
// this will GET templates from current user
templates: 'app/controllers/Ajax.php?action=readForTinymce&what=template&type=experiments_templates'
});

// Hook into the SelectionChange event - This is to make sure we reset our control variable correctly
tinymce.activeEditor.on('SelectionChange', function(e) {
// Check if the user has selected an image
if (tinymce.activeEditor.selection.getNode().tagName == 'IMG')
{
// Save all the details needed for replacing upload
// Then check for and get those details when you are handling file uploads
let url = tinymce.activeEditor.selection.getNode().src;
url = url.slice(url.lastIndexOf('app/'));
// Sometimes tinymce adds an identifier on modification
// This checks for and removes it
if (url.lastIndexOf('&') != -1){
url = url.slice(0, url.lastIndexOf('&'))
}
// Find the element in the uploads html section to got uploadid and itemid
let uploadsDestroyEl = $('a[href="'+url+'"]' ).prev();
tinymceEditImage.selected = true;
tinymceEditImage.uploadId = uploadsDestroyEl.data('id');
tinymceEditImage.itemId = uploadsDestroyEl.data('itemid');
tinymceEditImage.url = url;
}
else
{
tinymceEditImage = {selected:false, uploadId:'', itemId:'', url:''};
}
});

/* eslint-enable */

// IMPORT BODY OF LINKED ITEM INTO EDITOR
Expand Down
1 change: 1 addition & 0 deletions src/ts/langs/ca_ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t = {
"generic-delete-warning": "Eliminar això?",
"link-delete-warning": "Voleu eliminar aquest enllaç?",
"please-wait": "Si us plau, espera",
"replace-edited-file": "Voleu substituir el fitxer del servidor per aquesta edició?",
"request-filename": "Introduïu el nom del fitxer",
"step-delete-warning": "Voleu eliminar aquest pas?",
"tag-delete-warning": "Vols suprimir aquesta etiqueta?",
Expand Down
1 change: 1 addition & 0 deletions src/ts/langs/de_DE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t = {
"generic-delete-warning": "Element löschen?",
"link-delete-warning": "Diesen Link löschen?",
"please-wait": "Warten Sie mal",
"replace-edited-file": "Möchten Sie die Datei auf dem Server durch diese Bearbeitung ersetzen?",
"request-filename": "Geben Sie den Namen der Datei ein",
"step-delete-warning": "Diesen Schritt löschen?",
"tag-delete-warning": "Schlagwort löschen?",
Expand Down
1 change: 1 addition & 0 deletions src/ts/langs/en_GB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t = {
"generic-delete-warning": "Delete this?",
"link-delete-warning": "Delete this link?",
"please-wait": "Please wait…",
"replace-edited-file": "Do you want to replace the file on the server with this edit?",
"request-filename": "Enter name of the file",
"step-delete-warning": "Delete this step?",
"tag-delete-warning": "Delete this tag?",
Expand Down
1 change: 1 addition & 0 deletions src/ts/langs/es_ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t = {
"generic-delete-warning": "¿Eliminar esto?",
"link-delete-warning": "¿Eliminar este enlace?",
"please-wait": "Por favor espera",
"replace-edited-file": "¿Desea reemplazar el archivo en el servidor con esta edición?",
"request-filename": "Ingrese el nombre del archivo",
"step-delete-warning": "¿Eliminar este paso?",
"tag-delete-warning": "Eliminar esta etiqueta?",
Expand Down
1 change: 1 addition & 0 deletions src/ts/langs/fr_FR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t = {
"generic-delete-warning": "Supprimer ça ?",
"link-delete-warning": "Supprimer ce lien ?",
"please-wait": "Veuillez patienter…",
"replace-edited-file": "Voulez-vous remplacer le fichier sur le serveur par cette modification?",
"request-filename": "Entrez le nom du fichier",
"step-delete-warning": "Supprimer cette étape ?",
"tag-delete-warning": "Supprimer ce tag ?",
Expand Down
1 change: 1 addition & 0 deletions src/ts/langs/id_ID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t = {
"generic-delete-warning": "Hapus ini?",
"link-delete-warning": "Hapus tautan ini?",
"please-wait": "Mohon tunggu",
"replace-edited-file": "Apakah Anda ingin mengganti file di server dengan hasil edit ini?",
"request-filename": "Masukkan nama file",
"step-delete-warning": "Hapus langkah ini?",
"tag-delete-warning": "Hapus label ini?",
Expand Down
1 change: 1 addition & 0 deletions src/ts/langs/it_IT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t = {
"generic-delete-warning": "Cancellare questo?",
"link-delete-warning": "Eliminare questo collegamento?",
"please-wait": "Attendere prego",
"replace-edited-file": "Vuoi sostituire il file sul server con questa modifica?",
"request-filename": "Immettere il nome del file",
"step-delete-warning": "Cancellare questo passaggio?",
"tag-delete-warning": "Si vuol eliminare questo tag?",
Expand Down
1 change: 1 addition & 0 deletions src/ts/langs/ja_JP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t = {
"generic-delete-warning": "これを削除しますか?",
"link-delete-warning": "このリンクを削除しますか?",
"please-wait": "お待ちください",
"replace-edited-file": "サーバー上のファイルをこの編集で置き換えますか?",
"request-filename": "ファイルの名前を入力してください",
"step-delete-warning": "このステップを削除しますか?",
"tag-delete-warning": "このタグを削除しますか?",
Expand Down
1 change: 1 addition & 0 deletions src/ts/langs/ko_KR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t = {
"generic-delete-warning": "삭제할까요?",
"link-delete-warning": "링크를 삭제할까요?",
"please-wait": "기다려주세요",
"replace-edited-file": "서버의 파일을이 편집으로 바꾸시겠습니까?",
"request-filename": "파일 이름 입력",
"step-delete-warning": "단계를 삭제할까요?",
"tag-delete-warning": "이 태그를 삭제할까요?",
Expand Down
1 change: 1 addition & 0 deletions src/ts/langs/nl_BE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t = {
"generic-delete-warning": "Dit verwijderen?",
"link-delete-warning": "Deze link verwijderen?",
"please-wait": "Wacht alsjeblieft",
"replace-edited-file": "Wilt u het bestand op de server vervangen door deze bewerking?",
"request-filename": "Voer de naam van het bestand in",
"step-delete-warning": "Deze stap verwijderen?",
"tag-delete-warning": "Dit label verwijderen?",
Expand Down
1 change: 1 addition & 0 deletions src/ts/langs/pl_PL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t = {
"generic-delete-warning": "Czy na pewno chcesz to skasować?",
"link-delete-warning": "Usunąć ten link?",
"please-wait": "Proszę czekać",
"replace-edited-file": "Czy chcesz zastąpić plik na serwerze tą edycją?",
"request-filename": "Wpisz nazwę pliku",
"step-delete-warning": "Usunąć ten krok?",
"tag-delete-warning": "Usunąć ten tag?",
Expand Down
1 change: 1 addition & 0 deletions src/ts/langs/pt_BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t = {
"generic-delete-warning": "Apagar isto?",
"link-delete-warning": "Apagar este link?",
"please-wait": "Por favor, espere",
"replace-edited-file": "Você deseja substituir o arquivo no servidor por esta edição?",
"request-filename": "Digite o nome do arquivo",
"step-delete-warning": "Apagar este passo?",
"tag-delete-warning": "Apagar esta etiqueta?",
Expand Down
1 change: 1 addition & 0 deletions src/ts/langs/pt_PT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t = {
"generic-delete-warning": "Eliminar isto?",
"link-delete-warning": "Excluir este link?",
"please-wait": "Por favor, espere",
"replace-edited-file": "Você deseja substituir o arquivo no servidor por esta edição?",
"request-filename": "Digite o nome do arquivo",
"step-delete-warning": "Excluir esta etapa?",
"tag-delete-warning": "Excluir esta tag?",
Expand Down
1 change: 1 addition & 0 deletions src/ts/langs/ru_RU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t = {
"generic-delete-warning": "Удалить?",
"link-delete-warning": "Удалить эту ссылку?",
"please-wait": "Пожалуйста, подождите",
"replace-edited-file": "Вы хотите заменить файл на сервере этим редактированием?",
"request-filename": "Введите имя файла",
"step-delete-warning": "Удалить этот этап?",
"tag-delete-warning": "Удалить этот тег?",
Expand Down
1 change: 1 addition & 0 deletions src/ts/langs/sk_SK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t = {
"generic-delete-warning": "Odstrániť toto?",
"link-delete-warning": "Odstrániť tento odkaz?",
"please-wait": "Prosím čakajte",
"replace-edited-file": "Chcete nahradiť súbor na serveri touto úpravou?",
"request-filename": "Zadajte názov súboru",
"step-delete-warning": "Odstrániť tento krok?",
"tag-delete-warning": "Odstrániť túto značku?",
Expand Down
1 change: 1 addition & 0 deletions src/ts/langs/sl_SI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t = {
"generic-delete-warning": "Želite izbrisati?",
"link-delete-warning": "Želite izbrisati to povezavo?",
"please-wait": "Prosim počakaj",
"replace-edited-file": "Ali želite zamenjati datoteko na strežniku s tem urejanjem?",
"request-filename": "Vnesite ime datoteke",
"step-delete-warning": "Ali želite izbrisati ta korak?",
"tag-delete-warning": "Želite izbrisati to oznako?",
Expand Down
1 change: 1 addition & 0 deletions src/ts/langs/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t = {
"generic-delete-warning": "删除?",
"link-delete-warning": "删除此链接?",
"please-wait": "请稍候",
"replace-edited-file": "您是否要用此编辑替换服务器上的文件?",
"request-filename": "输入文件名",
"step-delete-warning": "删除此步骤?",
"tag-delete-warning": "删除这个标签?",
Expand Down
2 changes: 1 addition & 1 deletion src/ts/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ $(document).ready(function(){
// END PAGINATION

// THE CHECKBOXES
function getCheckedBoxes(): Array<object> {
function getCheckedBoxes() {
const checkedBoxes = [];
$('input[type=checkbox]:checked').each(function() {
checkedBoxes.push({
Expand Down

0 comments on commit 6e5969c

Please sign in to comment.