# In this file the possible permissions are defined.
# This should be compatible with the legacy Part-DB

groups:
  parts:
    label: "perm.group.parts"
  structures:
    label: "perm.group.structures"
  system:
    label: "perm.group.system"


perms: # Here comes a list with all Permission names (they have a perm_[name] coloumn in DB)

# Part related permissions

  parts: # e.g. this maps to perms_parts in User/Group database
    group: "parts"
    label: "perm.parts"
    operations: # Here are all possible operations are listed => the op name is mapped to bit value
      read:
        label: "perm.read"
        bit: 0
      edit:
        label: "perm.edit"
        bit: 2
        alsoSet: 'read'
      create:
        label: "perm.create"
        bit: 4
        alsoSet: ['read', 'edit']
      move:
        label: "perm.part.move"
        bit: 6
        alsoSet: 'read'
      delete:
        label: "perm.delete"
        bit: 8
        alsoSet: ['read', 'edit']
      search:
        label: "perm.part.search"
        bit: 10
      all_parts:
        label: "perm.part.all_parts"
        bit: 12
      no_price_parts:
        label: "perm.part.no_price_parts"
        bit: 14
      obsolete_parts:
        label: "perm.part.obsolete_parts"
        bit: 16
      unknown_instock_parts:
        label: "perm.part.unknown_instock_parts"
        bit: 18
      change_favorite:
        label: "perm.part.change_favorite"
        bit: 20
      show_favorite_parts:
        label: "perm.part.show_favorite"
        bit: 24
      show_last_edit_parts:
        label: "perm.part.show_last_edit_parts"
        bit: 26
      show_users:
        label: "perm.part.show_users"
        bit: 28
      show_history:
        label: "perm.part.show_history"
        bit: 30

  parts_name:  &PART_ATTRIBUTE # We define a template here, that we can use for all part attributes.
    label: "perm.part.name"
    group: "parts"
    operations:
      read:
        label: "perm.read"
        bit: 0
      edit:
        label: "perm.edit"
        bit: 2
        alsoSet: 'read'

  parts_description:
    <<: *PART_ATTRIBUTE
    label: "perm.part.description"

  parts_instock:
    <<: *PART_ATTRIBUTE
    label: "perm.part.instock"

  parts_mininstock:
    <<: *PART_ATTRIBUTE
    label: "perm.part.mininstock"

  parts_footprint:
    <<: *PART_ATTRIBUTE
    label: "perm.part.mininstock"

  parts_comment:
    <<: *PART_ATTRIBUTE
    label: "perm.part.comment"

  parts_storelocation:
    <<: *PART_ATTRIBUTE
    label: "perm.part.storelocation"

  parts_manufacturer:
    <<: *PART_ATTRIBUTE
    label: "perm.part.manufacturer"

  parts_orderdetails:
    <<: *PART_ATTRIBUTE
    label: "perm.part.orderdetails"

  parts_prices:
    <<: *PART_ATTRIBUTE
    label: "perm.part.prices"

  parts_attachments:
    <<: *PART_ATTRIBUTE
    label: "perm.part.attachments"

  parts_order:
    <<: *PART_ATTRIBUTE
    label: "perm.part.order"

  storelocations: &PART_CONTAINING
    label: "perm.storelocations"
    group: "structures"
    operations:
      read:
        label: "perm.read"
        bit: 0
      edit:
        label: "perm.edit"
        bit: 2
        alsoSet: 'read'
      create:
        label: "perm.create"
        bit: 4
        alsoSet: ['read', 'edit']
      move:
        label: "perm.move"
        bit: 6
      delete:
        label: "perm.delete"
        bit: 8
        alsoSet: ['read', 'edit']
      list_parts:
        label: "perm.list_parts"
        bit: 10
      show_users:
        label: "perm.list_parts"
        bit: 12

  footprints:
    <<: *PART_CONTAINING
    label: "perm.part.footprints"

  categories:
    <<: *PART_CONTAINING
    label: "perm.part.categories"

  suppliers:
    <<: *PART_CONTAINING
    label: "perm.part.supplier"

  manufacturers:
    <<: *PART_CONTAINING
    label: "perm.part.manufacturers"

  devices:
    <<: *PART_CONTAINING
    label: "perm.part.devices"

  attachment_types:
    <<: *PART_CONTAINING
    label: "perm.part.attachment_types"

  tools:
    label: "perm.part.tools"
    operations:
      import:
        label: "perm.tools.import"
        bit: 0
      labels:
        label: "perm.tools.labels"
        bit: 2
      calculator:
        label: "perm.tools.calculator"
        bit: 4
      footprints:
        label: "perm.tools.footprints"
        bit: 6
      ic_logos:
        label: "perm.tools.ic_logos"
        bit: 8
      statistics:
        label: "perm.tools.statistics"
        bit: 10

  groups:
    label: "perm.groups"
    group: "system"
    operations:
      read:
        label: "perm.read"
        bit: 0
      edit:
        label: "perm.edit"
        bit: 2
        alsoSet: 'read'
      create:
        label: "perm.create"
        bit: 4
        alsoSet: ['read', 'edit']
      move:
        label: "perm.move"
        bit: 6
      delete:
        label: "perm.delete"
        bit: 8
        alsoSet: ['read', 'delete']
      edit_permissions:
        label: "perm.edit_permissions"
        alsoSet: ['read', 'edit']
        bit: 10

  users:
    label: "perm.users"
    group: "system"
    operations:
      read:
        label: "perm.read"
        bit: 0
      create:
        label: "perm.create"
        alsoSet: ['read', 'edit_username', 'edit_infos']
        bit: 4
      delete:
        label: "perm.delete"
        alsoSet: ['read', 'edit']
        bit: 8
      edit_username:
        label: "perm.users.edit_user_name"
        alsoSet: ['read']
        bit: 2
      change_group:
        label: "perm.users.edit_change_group"
        alsoSet: 'read'
        bit: 6
      edit_infos:
        label: "perm.users.edit_infos"
        alsoSet: 'read'
        bit: 10
      edit_permissions:
        label: "perm.users.edit_permissions"
        alsoSet: 'read'
        bit: 12
      set_password:
        label: "perm.users.set_password"
        alsoSet: 'set_read'
        bit: 14
      change_user_settings:
        label: "perm.users.change_user_settings"
        bit: 16

  database:
    label: "perm.database"
    group: "system"
    operations:
      see_status:
        label: "perm.database.see_status"
        bit: 0
      update_db:
        label: "perm.database.update_db"
        bit: 2
        alsoSet: 'see_status'
      read_db_settings:
        label: "perm.database.read_db_settings"
        bit: 4
      write_db_settings:
        label: "perm.database.write_db_settings"
        alsoSet: ['read_db_settings', 'see_status']
        bit: 2

  config:
    label: "perm.config"
    group: "system"
    operations:
      read_config:
        label: "perm.config.read_config"
        bit: 0
      edit_config:
        label: "perm.config.edit_config"
        alsoSet: 'read_config'
        bit: 2
      server_info:
        label: "perm.config.server_info"
        bit: 6

  system:
    label: "perm.system"
    group: "system"
    operations:
      use_debug:
        label: "perm.config.use_debug"
        bit: 0
      show_logs:
        label: "perm.show_logs"
        bit: 2
      delete_logs:
        label: "perm.delete_logs"
        alsoSet: 'show_logs'
        bit: 4

  devices_parts:
    label: "perm.device_parts"
    group: "parts"
    operations:
      read:
        label: "perm.read"
        bit: 0
      edit:
        label: "perm.edit"
        alsoSet: 'read'
        bit: 2
      create:
        label: "perm.create"
        alsoSet: ['edit', 'read']
        bit: 6
      delete:
        label: "perm.delete"
        alsoSet: ['edit', 'read']
        bit: 8

  self:
    label: "perm.self"
    operations:
      edit_infos:
        label: "perm.self.edit_infos"
        bit: 0
      edit_username:
        label: "perm.self.edit_username"
        bit: 2
      show_permissions:
        label: "perm.self.show_permissions"
        bit: 4
      show_logs:
        label: "perm.self.show_logs"
        bit: 6

  labels:
    label: "perm.labels"
    operations:
      create_labels:
        label: "perm.self.create_labels"
        bit: 0
      edit_options:
        label: "perm.self.edit_options"
        bit: 2
      delete_profiles:
        label: "perm.self.delete_profiles"
        bit: 4
      edit_profiles:
        label: "perm.self.edit_profiles"
        bit: 6


