<commit_before>angular.module('jumplink.cms.event', [
    'mgcrea.ngStrap',
    'angular-medium-editor',
    'angularFileUpload',
    'angularMoment',
    'ngFocus',
    'ngAsync',
    'sails.io',
    'jumplink.cms.utilities',
  ])

  .service('EventService', function (moment, UtilityService, $sailsSocket, $async, $log, focus, $modal, FileUploader) {

    var editModal = null;
    var typeModal = null;
    var types = ['lecture', 'panel discussion', 'travel', 'info', 'food', 'other'];

    var validate = function (event, cb) {
      if(event.title) {
        return fix(event, cb)
      } else {
        if(cb) cb("Title not set", event);
        else return null;
      }
    }

    var chooseType = function(event, type, hide) {
      event.type = type;
      hide();
    };

    var openTypeChooserModal = function(event) {
      typeModal.$scope.event = event;
      //- Show when some event occurs (use $promise property to ensure the template has been loaded)
      typeModal.$promise.then(typeModal.show);
    };

    var setModals = function($scope) {

      editModal = $modal({title: 'Ereignis bearbeiten', templateUrl: '/views/modern/events/editmodal.jade', show: false});
      editModal.$scope.ok = false;
      editModal.$scope.accept = function (hide) {
        editModal.$scope.ok = true;
        hide();
      };
      editModal.$scope.abort = function (hide) {
        editModal.$scope.ok = false;
        hide();
      }
      editModal.$scope.uploader = new FileUploader({url: 'timeline/upload', removeAfterUpload: true});
      editModal.$scope.openTypeChooserModal = openTypeChooserModal;

      editModal.$scope.uploader.onCompleteItem = function(fileItem, response, status, headers) {
        fileItem.event.download = response.files[0].uploadedAs;
      };

      editModal.$scope.uploader.onProgressItem = function(fileItem, progress) {
        console.info('onProgressItem', fileItem, progress);
      };

      editModal.$scope.upload = function(fileItem, event) {
        fileItem.event = event;
        fileItem.upload();
      };

      typeModal = $modal({title: 'Typ wählen', templateUrl: '/views/modern/events/typechoosermodal', show: false});
      typeModal.$scope.chooseType = chooseType;

      editModal.$scope.$on('modal.hide.before',function(event, editModal) {
        $log.debug("edit closed", event, editModal);
        if(editModal.$scope.ok) {
          return validate(editModal.$scope.event, editModal.$scope.callback);
        } else {
          if(editModal.$scope.callback) editModal.$scope.callback("discarded", editModal.$scope.event);
        }<commit_msg>bugfix<commit_after>angular.module('jumplink.cms.event', [
    'mgcrea.ngStrap',
    'angular-medium-editor',
    'angularFileUpload',
    'angularMoment',
    'ngFocus',
    'ngAsync',
    'sails.io',
    'jumplink.cms.utilities',
  ])

  .service('EventService', function (moment, UtilityService, $sailsSocket, $async, $log, focus, $modal, FileUploader) {

    var editModal = null;
    var typeModal = null;
    var types = ['lecture', 'panel discussion', 'travel', 'info', 'food', 'other'];

    var validate = function (event, cb) {
      if(event.title) {
        return fix(event, cb)
      } else {
        if(cb) cb("Title not set", event);
        else return null;
      }
    }

    var chooseType = function(event, type, hide) {
      event.type = type;
      hide();
    };

    var openTypeChooserModal = function(event) {
      typeModal.$scope.event = event;
      //- Show when some event occurs (use $promise property to ensure the template has been loaded)
      typeModal.$promise.then(typeModal.show);
    };

    var setModals = function($scope) {

      editModal = $modal({title: 'Ereignis bearbeiten', templateUrl: '/views/modern/events/editmodal.jade', show: false});
      editModal.$scope.ok = false;
      editModal.$scope.accept = function (hide) {
        editModal.$scope.ok = true;
        hide();
      };
      editModal.$scope.abort = function (hide) {
        editModal.$scope.ok = false;
        hide();
      }
      editModal.$scope.uploader = new FileUploader({url: 'timeline/upload', removeAfterUpload: true});
      editModal.$scope.openTypeChooserModal = openTypeChooserModal;

      editModal.$scope.uploader.onCompleteItem = function(fileItem, response, status, headers) {
        fileItem.event.download = response.files[0].uploadedAs;
      };

      editModal.$scope.uploader.onProgressItem = function(fileItem, progress) {
        console.info('onProgressItem', fileItem, progress);
      };

      editModal.$scope.upload = function(fileItem, event) {
        fileItem.event = event;
        fileItem.upload();
      };

      typeModal = $modal({title: 'Typ wählen', templateUrl: '/views/modern/events/typechoosermodal.jade', show: false});
      typeModal.$scope.chooseType = chooseType;

      editModal.$scope.$on('modal.hide.before',function(event, editModal) {
        $log.debug("edit closed", event, editModal);
        if(editModal.$scope.ok) {
          return validate(editModal.$scope.event, editModal.$scope.callback);
        } else {
          if(editModal.$scope.callback) editModal.$scope.callback("discarded", editModal.$scope.event);
        }
{'fraction_non_alphanumeric': 0.14359464627151053, 'fraction_numerical': 0.0003824091778202677, 'mean_word_length': 2.921289355322339, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5729794', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1557, 'n_words': 314}