쇼룸(showroom) 사용자 관리 YAML 코드

셀렉트 쇼룸의 사용자 관리 페이지의 YAML 코드입니다.

궁금한 점은 댓글이나 이메일, 서비스 내 채팅, 슬랙 등으로 편하게 문의주세요.

menus:
- path: users
  name: 💁     사용자 관리

- type: search
  label: 찾기
  placeholder: "연락처 4자리 (예: 0000)"
  redirect: users?phone_number={{value}}

pages:
- path: users
  blocks: 
    - type: query
      resource: mysql.qa
      sqlType: select
      sql: >
        SELECT id, name, email, phone_number, role, created_at
        FROM users
        WHERE (LENGTH(:id)=0 OR id = :id)
        AND (LENGTH(:name)=0 OR name LIKE CONCAT('%', :name, '%'))
        AND (LENGTH(:email)=0 OR email LIKE CONCAT('%', :email, '%'))
        AND (LENGTH(:phone_number)=0 OR phone_number LIKE CONCAT('%', :phone_number, '%'))        
        AND (LENGTH(:created_at1 + :created_at2)=0 OR created_at BETWEEN :created_at1 AND :created_at2)
      params:
        - key: id
          label: ID
          placeholder: 12345
        - key: name
          label: 이름
          placeholder: 홍길동
        - key: email
          label: 이메일
          placeholder: mail@mail.com
        - key: phone_number
          label: 연락처
          placeholder: 010-0000-0000
        - key: created_at
          label: 생성일
          format: date
          range: true
          defaultValueFn:
            return [
              moment().add(-1, 'year').format('YYYY-MM-DD')
            , moment().add(1, 'day').format('YYYY-MM-DD')
            ]
          showButtons: true
          shortcuts:
            - label: 지난주
              relative: true
              from:
                offset: -7
                period: day
              to:
                offset: -7
                period: day
            - label: 다음주
              relative: true
              from:
                offset: 7
                period: day
              to:
                offset: 7
                period: day
            - label: 초기화
              reset: true
      columns:
        id:
          label: ID
        name:
          label: 이름
        email:
          label: 이메일
        phone_number:
          label: 연락처
        role:
          label: 역할
          color:
            PM: red
            개발자: blue
            마케터: green
            디자이너: yellow
            매니저: gray
        created_at:
          label: 생성일
      viewModal: 
        mode: side
        blocks:
          - type: query
            resource: mysql.qa
            sqlType: select
            sql: >
              SELECT * FROM users WHERE id = :id
            params:
              - key: id
                valueFromRow: id
            display: form
            columns: 
              id:
                label: ID
              name:
                label: 이름
                updateOptions:
                  type: query
                  resource: mysql.qa
                  sql: UPDATE users SET name = :value, updated_at = NOW() WHERE id = :id
              email:
                label: 이메일
                updateOptions:
                  type: query
                  resource: mysql.qa
                  sql: UPDATE users SET email = :value, updated_at = NOW() WHERE id = :id
                  params:
                    - key: id
                      valueFromRow: id
                format: email
              phone_number:
                label: 연락처
                updateOptions:
                  type: query
                  resource: mysql.qa
                  sql: UPDATE users SET phone_number = :value, updated_at = NOW() WHERE id = :id        
              role:
                label: 역할
                updateOptions:
                  type: query
                  resource: mysql.qa
                  sql: UPDATE users SET role = :value, updated_at = NOW() WHERE id = :id        
              created_at:
                label: 생성일 
              updated_at:
                label: 수정일 
              nick_name:
                label: 닉네임
                updateOptions:
                  type: query
                  resource: mysql.qa
                  sql: UPDATE users SET nick_name = :value, updated_at = NOW() WHERE id = :id        
              user_id:
                hidden: true
              is_withdrawal:
                label: 회수
                valueAs:
                  1: 회수됨
                  0: 복구
            actions:
              - label: 회수
                single: true
                placement: bottom right
                button:
                  type: danger-light
                type: query
                resource: mysql.qa
                sql: UPDATE users SET is_withdrawal = 1, updated_at = NOW() WHERE id = :id
                reloadAfterSubmit: true
              - label: 복구
                single: true
                placement: bottom left
                button:
                  type: primary
                type: query
                resource: mysql.qa
                sql: UPDATE users SET is_withdrawal = 0, updated_at = NOW() WHERE id = :id
                reloadAfterSubmit: true