From 219204087a61a3bf875d6d200f170cd08696d545 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Mon, 21 Nov 2016 15:24:11 +0100 Subject: [PATCH] fixing duration in topic import (fixes #2671) --- openslides/topics/static/js/topics/site.js | 17 ++++++++++++++++- .../static/templates/topics/topic-import.html | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/openslides/topics/static/js/topics/site.js b/openslides/topics/static/js/topics/site.js index 55d332790..cb389942c 100644 --- a/openslides/topics/static/js/topics/site.js +++ b/openslides/topics/static/js/topics/site.js @@ -328,7 +328,22 @@ angular.module('OpenSlidesApp.topics.site', ['OpenSlidesApp.topics']) } // duration if (item.duration) { - item.duration = item.duration.replace(quotionRe, '$1'); + var time = item.duration.replace(quotionRe, '$1').split(':'), + len = time.length, + data = ''; + if (len > 1 && !isNaN(time[len-2]) && !isNaN(time[len-1])) { // minutes and hours + // e.g.: [sl:1000:]10:34 (the [] will not be parsed) + data = (+time[len-2]) * 60 + (+time[len-1]); + } else if (len == 1) { // just interpret minutes + data = (+time[0]); + } else { + data = null; + } + + if (data < 0 || data === '') { + data = null; // no negative duration + } + item.duration = data; } else { item.duration = null; } diff --git a/openslides/topics/static/templates/topics/topic-import.html b/openslides/topics/static/templates/topics/topic-import.html index 5bb2cddd3..2676cd505 100644 --- a/openslides/topics/static/templates/topics/topic-import.html +++ b/openslides/topics/static/templates/topics/topic-import.html @@ -104,7 +104,7 @@ {{ item.title }} {{ item.text | limitTo:80 }}{{ item.text.length > 80 ? '...' : '' }} - {{ item.duration }} + {{ item.duration | osMinutesToTime }} {{ item.comment }} {{ item.is_hidden }}