 
   populateTable(roles)
 
+  $("#addSelfRightUi button").click ->
+    console.log("Clicking the self button")
+    option = $('#addSelfRightUi option:selected')
+    if (option.val() == 'none')
+      return
+    text = option.text()
+    right = createLabel('right', text)
+    right = wrapInputWithDeleteButton(right, "span", text)
+    $("#addSelfRightUi").parent().append(right)
+    $("#addSelfRightUi").parent().append(" ")
+    populateRightComboBox($(@).parents("tr"))
+    enableSaveButtonIfPossible($(@).parents("tr"))
+
   $("#addRightUi button").click ->
+    console.log("The regular button clicked")
     option = $('#addRightUi option:selected')
     if (option.val() == 'none')
       return

    return rights

getSelfRights = (tr) ->
#    rights = []
#    tr.find(SELF_RIGHT_COL).find(".customLabel").each ->
#      rights.push($(@).text())
#    return rights
  return null

getRoles = (tr) ->
    roles = []

    if ($(@).val() != "none")
      $(@).remove()

  $("#addSelfRightUi option").each ->
    if ($(@).val() != "none")
      $(@).remove()

  for right in defaultRights
    if (curRights.indexOf(right) < 0)
      $("#addRightUi select").append($("<option></option>").val(right).text(right))

  for right in selfRights
    if (curSelfRights.indexOf(right) < 0)
      $("#addSelfRightUi select").append($("<option></option>").val(right).text(right))

wrapInputWithDeleteButton = (input, type, name) ->
  div = $('<span>').addClass("input-append")
