### # Copyright (C) 2014-2017 Andrey Antukh # Copyright (C) 2014-2017 Jesús Espino Garcia # Copyright (C) 2014-2017 David Barragán Merino # Copyright (C) 2014-2017 Alejandro Alonso # Copyright (C) 2014-2017 Juan Francisco Alcántara # Copyright (C) 2014-2017 Xavi Julian # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # File: modules/components/wysiwyg/item-wysiwyg.directive.coffee ### # Used in details descriptions ItemWysiwyg = ($modelTransform, $rootscope, $confirm, attachmentsFullService, $translate) -> link = ($scope, $el, $attrs) -> $scope.editableDescription = false $scope.saveDescription = (description, cb) -> transform = $modelTransform.save (item) -> item.description = description return item transform.then -> $confirm.notify("success") $rootscope.$broadcast("object:updated") transform.then null, -> $confirm.notify("error") transform.finally(cb) uploadFile = (file, cb) -> return attachmentsFullService.addAttachment($scope.project.id, $scope.item.id, $attrs.type, file).then (result) -> cb(result.getIn(['file', 'name']), result.getIn(['file', 'url'])) $scope.uploadFiles = (files, cb) -> for file in files uploadFile(file, cb) $scope.$watch $attrs.model, (value) -> return if not value $scope.item = value $scope.version = value.version $scope.storageKey = $scope.project.id + "-" + value.id + "-" + $attrs.type $scope.$watch 'project', (project) -> return if !project $scope.editableDescription = project.my_permissions.indexOf($attrs.requiredPerm) != -1 return { scope: true, link: link, template: """
{{'COMMON.DESCRIPTION.NO_DESCRIPTION' | translate}}
""" } angular.module("taigaComponents") .directive("tgItemWysiwyg", [ "$tgQueueModelTransformation", "$rootScope", "$tgConfirm", "tgAttachmentsFullService", "$translate", ItemWysiwyg])