- remote = flag.has_children ? false : true
%div{ id: "#{flag.fullname}" }
  .flagimage
    - if flag.new_record?
      %div{ class: "#{"current_flag_state icons-#{flag.flag}_#{flag.status}_grey"} icon_24" }
    - else
      %div{ class: "#{"current_flag_state icons-#{flag.flag}_#{flag.status}_blue"} icon_24" }
    .hidden.flagtoggle
      - if flag.new_record?
        .iconwrapper
          %div{ class: "icons-#{flag.flag}_disable_blue icon_24" }
        = link_to 'Disable', { action: :create_flag,
            project: @project,
            package: @package,
            flag: flag.flag,
            status: 'disable',
            repository: flag.repo,
            architecture: flag.arch },
          id: "#{flag.fullname}_disable", class: "flag_spinner_trigger_#{flag.flag}", method: :post, remote: remote
        .iconwrapper
          %div{class: "icons-#{flag.flag}_enable_blue icon_24"}
        = link_to 'Enable', { action: :create_flag,
            project: @project,
            package: @package,
            flag: flag.flag,
            status: 'enable',
            repository: flag.repo,
            architecture: flag.arch},
          id: "#{flag.fullname}_enable", class: "flag_spinner_trigger_#{flag.flag}", method: :post, remote: remote
      - else
        - if flag.status == 'enable'
          .iconwrapper
            %div{ class: "icons-#{flag.flag}_disable_blue icon_24" }
          = link_to('Disable', { action: :toggle_flag, project: @project, package: @package, flag: flag }, id: "#{flag.fullname}_disable", class: "flag_spinner_trigger_#{flag.flag}", method: :put, remote: remote)
        - else
          .iconwrapper
            %div{ class: "icons-#{flag.flag}_enable_blue icon_24" }
          = link_to 'Enable', { action: :toggle_flag, project: @project, package: @package, flag: flag }, id: "#{flag.fullname}_enable", class: "flag_spinner_trigger_#{flag.flag}", method: :put, remote: remote
        .iconwrapper
          %div{ class: "icons-#{flag.flag}_#{flag.default_status}_grey icon_24" }
        = link_to "Take default (#{flag.default_status})", { action: :remove_flag, project: @project, package: @package, flag: flag }, id: "#{flag.fullname}_remove", class: "flag_spinner_trigger_#{flag.flag}", method: :delete, remote: remote
