function addTo(task) {
  var data = task.getData();
  if (data.id) {
    return;
  }
  var cData = Current.company.getData();
  var curId = cData.currentId || 1;
  curId++;
  data.id = 'ID' + curId;
  task.setData(data);
  cData.currentId = curId;
  Current.company.setData(cData);
}

function getId(task, recur) {
  var data = task.getData();
  if (!data.id) {
    if (recur) {
      return;
    }
    addTo(task);
    return getId(task, true);
  }
  return data.id;
}

Items.onAdd = function(task) {
  if (task.type !== 'Task') {
    return;
  }
  addTo(task);
};

var style = {
  position: 'absolute',
  fontSize: '9px',
  right: '4px',
  top: '-1px',
  fontWeight: 'bold'
};

Items.onList = function(obj, arr) {
  if (obj.type === 'Column') {
    arr.forEach(function(t) {
      var id = getId(t);
      var el = UI.text(id);
      el.style = style;
      t.ui.clear();
      t.ui.add(el);
    });
  }
  return arr;
};
