Add support for checkboxes
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -1197,6 +1197,17 @@ input.input-inline {
|
|||||||
white-space: pre;
|
white-space: pre;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input[type=checkbox] {
|
||||||
|
margin: 0px 10px 0px 0px;
|
||||||
|
line-height: 10px;
|
||||||
|
font-size: 10px;
|
||||||
|
display: inline-block;
|
||||||
|
min-height: 12px;
|
||||||
|
}
|
||||||
|
li input[type=checkbox] {
|
||||||
|
margin: 0px 10px 0px -20px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -25,18 +25,20 @@
|
|||||||
import app from './App.js';
|
import app from './App.js';
|
||||||
import md from 'angular-markdown-it';
|
import md from 'angular-markdown-it';
|
||||||
import markdownitLinkTarget from 'markdown-it-link-target';
|
import markdownitLinkTarget from 'markdown-it-link-target';
|
||||||
|
import markdownitCheckbox from 'legacy/markdown-it-checkbox.js';
|
||||||
|
|
||||||
app.config(function ($provide, $interpolateProvider, $httpProvider, $urlRouterProvider, $stateProvider, $compileProvider, markdownItConverterProvider) {
|
app.config(function ($provide, $interpolateProvider, $httpProvider, $urlRouterProvider, $stateProvider, $compileProvider, markdownItConverterProvider) {
|
||||||
'use strict';
|
'use strict';
|
||||||
$httpProvider.defaults.headers.common.requesttoken = oc_requesttoken;
|
$httpProvider.defaults.headers.common.requesttoken = oc_requesttoken;
|
||||||
|
|
||||||
|
|
||||||
$compileProvider.debugInfoEnabled(true);
|
$compileProvider.debugInfoEnabled(true);
|
||||||
|
|
||||||
markdownItConverterProvider.use(markdownitLinkTarget, {
|
markdownItConverterProvider.use(markdownitLinkTarget, {
|
||||||
breaks: true,
|
breaks: true,
|
||||||
linkify: true,
|
linkify: true,
|
||||||
xhtmlOut: true
|
xhtmlOut: true
|
||||||
});
|
}).use(markdownitCheckbox);
|
||||||
|
|
||||||
$urlRouterProvider.otherwise('/');
|
$urlRouterProvider.otherwise('/');
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
/* global app moment */
|
/* global app moment */
|
||||||
import app from '../app/App.js';
|
import app from '../app/App.js';
|
||||||
|
|
||||||
app.controller('CardController', function ($scope, $rootScope, $location, $stateParams, $interval, $timeout, $filter, BoardService, CardService, StackService, StatusService) {
|
app.controller('CardController', function ($scope, $rootScope, $sce, $location, $stateParams, $interval, $timeout, $filter, BoardService, CardService, StackService, StatusService, markdownItConverter) {
|
||||||
$scope.sidebar = $rootScope.sidebar;
|
$scope.sidebar = $rootScope.sidebar;
|
||||||
$scope.status = {
|
$scope.status = {
|
||||||
lastEdit: 0,
|
lastEdit: 0,
|
||||||
@@ -38,9 +38,19 @@ app.controller('CardController', function ($scope, $rootScope, $location, $state
|
|||||||
|
|
||||||
$scope.statusservice.retainWaiting();
|
$scope.statusservice.retainWaiting();
|
||||||
|
|
||||||
|
$scope.description = function() {
|
||||||
|
return $scope.rendered;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.updateMarkdown = function(content) {
|
||||||
|
// only trust the html from markdown-it-checkbox
|
||||||
|
$scope.rendered = $sce.trustAsHtml(markdownItConverter.render(content || ''));
|
||||||
|
};
|
||||||
|
|
||||||
CardService.fetchOne($scope.cardId).then(function (data) {
|
CardService.fetchOne($scope.cardId).then(function (data) {
|
||||||
$scope.statusservice.releaseWaiting();
|
$scope.statusservice.releaseWaiting();
|
||||||
$scope.archived = CardService.getCurrent().archived;
|
$scope.archived = CardService.getCurrent().archived;
|
||||||
|
$scope.updateMarkdown(CardService.getCurrent().description);
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -51,7 +61,42 @@ app.controller('CardController', function ($scope, $rootScope, $location, $state
|
|||||||
$scope.status.cardRename = true;
|
$scope.status.cardRename = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$scope.cardEditDescriptionShow = function ($event) {
|
|
||||||
|
$scope.toggleCheckbox = function (id) {
|
||||||
|
$('#markdown input[type=checkbox]').attr('disabled', true);
|
||||||
|
$scope.status.edit = angular.copy(CardService.getCurrent());
|
||||||
|
var reg = /\[(X|\s|\_|\-)\]\s(.*)/ig;
|
||||||
|
var nth = 0;
|
||||||
|
$scope.status.edit.description = $scope.status.edit.description.replace(reg, function (match, i, original) {
|
||||||
|
if (nth++ === id) {
|
||||||
|
var result;
|
||||||
|
if (match.match(/^\[\s\]/i))
|
||||||
|
result = match.replace(/\[\s\]/i, '[x]');
|
||||||
|
if (match.match(/^\[x\]/i))
|
||||||
|
result = match.replace(/\[x\]/i, '[ ]');
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return match;
|
||||||
|
});
|
||||||
|
CardService.update($scope.status.edit).then(function (data) {
|
||||||
|
var header = $('.section-header.card-description');
|
||||||
|
header.find('.save-indicator.unsaved').hide();
|
||||||
|
header.find('.save-indicator.saved').fadeIn(250).fadeOut(1000);
|
||||||
|
StackService.updateCard($scope.status.edit);
|
||||||
|
});
|
||||||
|
$('#markdown input[type=checkbox]').removeAttr('disabled');
|
||||||
|
|
||||||
|
};
|
||||||
|
$scope.clickCardDescription = function ($event) {
|
||||||
|
var checkboxId = $($event.target).data('id');
|
||||||
|
if ($event.target.tagName === 'LABEL') {
|
||||||
|
$scope.toggleCheckbox(checkboxId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($event.target.tagName === 'INPUT') {
|
||||||
|
$scope.toggleCheckbox(checkboxId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (BoardService.isArchived() || CardService.getCurrent().archived) {
|
if (BoardService.isArchived() || CardService.getCurrent().archived) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -71,8 +116,9 @@ app.controller('CardController', function ($scope, $rootScope, $location, $state
|
|||||||
$interval(function() {
|
$interval(function() {
|
||||||
var currentTime = Date.now();
|
var currentTime = Date.now();
|
||||||
var timeSinceEdit = currentTime-$scope.status.lastEdit;
|
var timeSinceEdit = currentTime-$scope.status.lastEdit;
|
||||||
if (timeSinceEdit > 1000 && $scope.status.lastEdit > $scope.status.lastSave) {
|
if (timeSinceEdit > 1000 && $scope.status.lastEdit > $scope.status.lastSave && !$scope.status.saving) {
|
||||||
$scope.status.lastSave = currentTime;
|
$scope.status.lastSave = currentTime;
|
||||||
|
$scope.status.saving = true;
|
||||||
var header = $('.section-header.card-description');
|
var header = $('.section-header.card-description');
|
||||||
header.find('.save-indicator.unsaved').fadeIn(500);
|
header.find('.save-indicator.unsaved').fadeIn(500);
|
||||||
CardService.update($scope.status.edit).then(function (data) {
|
CardService.update($scope.status.edit).then(function (data) {
|
||||||
@@ -80,6 +126,7 @@ app.controller('CardController', function ($scope, $rootScope, $location, $state
|
|||||||
header.find('.save-indicator.unsaved').hide();
|
header.find('.save-indicator.unsaved').hide();
|
||||||
header.find('.save-indicator.saved').fadeIn(250).fadeOut(1000);
|
header.find('.save-indicator.saved').fadeIn(250).fadeOut(1000);
|
||||||
StackService.updateCard($scope.status.edit);
|
StackService.updateCard($scope.status.edit);
|
||||||
|
$scope.status.saving = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, 500, 0, false);
|
}, 500, 0, false);
|
||||||
|
|||||||
@@ -98,14 +98,13 @@
|
|||||||
placeholder="<?php p($l->t('Add a card description…')); ?>"
|
placeholder="<?php p($l->t('Add a card description…')); ?>"
|
||||||
ng-blur="cardUpdate(status.edit)"
|
ng-blur="cardUpdate(status.edit)"
|
||||||
ng-model="status.edit.description"
|
ng-model="status.edit.description"
|
||||||
ng-change="cardEditDescriptionChanged()"
|
ng-change="cardEditDescriptionChanged(); updateMarkdown(status.edit.description)"
|
||||||
autofocus-on-insert> </textarea>
|
autofocus-on-insert> </textarea>
|
||||||
<div class="container" ng-click="cardEditDescriptionShow($event)"
|
<div class="container" ng-click="clickCardDescription($event)"
|
||||||
ng-if="!status.cardEditDescription" ng-animate>
|
ng-if="!status.cardEditDescription" ng-animate>
|
||||||
<div markdown-it="cardservice.getCurrent().description"
|
<div id="markdown" ng-bind-html="description()">{{ description() }}</div>
|
||||||
id="markdown"></div>
|
|
||||||
<div class="placeholder"
|
<div class="placeholder"
|
||||||
ng-if="!cardservice.getCurrent().description"><?php p($l->t('Add a card description…')); ?></div>
|
ng-if="!description()"><?php p($l->t('Add a card description…')); ?></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user