Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

tagging on paste disabled? #1286

Closed
logannc opened this issue Nov 4, 2015 · 1 comment
Closed

tagging on paste disabled? #1286

logannc opened this issue Nov 4, 2015 · 1 comment

Comments

@logannc
Copy link

logannc commented Nov 4, 2015

  ctrl.searchInput.on('paste', function (e) {
    var data = e.originalEvent.clipboardData.getData('text/plain');
    console.log(data);
    console.log(data.length);
    console.log(ctrl.taggingTokens);
    console.log(ctrl.tagging);
    if (data && data.length > 0 && ctrl.taggingTokens.isActivated && ctrl.tagging.fct) {
      console.log(ctrl.taggingTokens.tokens);
      var items = data.split(ctrl.taggingTokens.tokens[0]); // split by first token only
      console.log(items);
      if (items && items.length > 0) {
        angular.forEach(items, function (item) {
          var newItem = ctrl.tagging.fct(item);
          if (newItem) {
            ctrl.select(newItem, true);
          }
        });
        e.preventDefault();
        e.stopPropagation();
      }
    }
  });

could be changed to

  ctrl.searchInput.on('paste', function (e) {
    var data = e.originalEvent.clipboardData.getData('text/plain');
    console.log(data);
    console.log(data.length);
    console.log(ctrl.taggingTokens);
    console.log(ctrl.tagging);
    if (data && data.length > 0 && ctrl.taggingTokens.isActivated) { // LINE CHANGED
      console.log(ctrl.taggingTokens.tokens);
      var items = data.split(ctrl.taggingTokens.tokens[0]); // split by first token only
      console.log(items);
      if (items && items.length > 0) {
        angular.forEach(items, function (item) {
          var newItem = item.trim(); // ADDED
          if (ctrl.tagging.fct) { // ADDED
            newItem = ctrl.tagging.fct(item);
          }
          if (newItem) {
            ctrl.select(newItem, true);
          }
        });
        e.preventDefault();
        e.stopPropagation();
      }
    }
  });

and it appears to work without incident.

I confess that I do not know what fct is supposed to do.

attrs.$observe('tagging', function() {
          if(attrs.tagging !== undefined)
          {
            // $eval() is needed otherwise we get a string instead of a boolean
            var taggingEval = scope.$eval(attrs.tagging);
            $select.tagging = {isActivated: true, fct: taggingEval !== true ? taggingEval : undefined};
          }
          else
          {
            $select.tagging = {isActivated: false, fct: undefined};
          }
        });

It is set here, which doesn't make a lot of sense to me.

@logannc
Copy link
Author

logannc commented Nov 4, 2015

I see #1276 now. I think that this is all you need to do for allowing it in tagging mode?

@logannc logannc closed this as completed Mar 23, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant