주요 콘텐츠로 건너뛰기

priorities

설명

선택 사항. 우선순위 데이터를 포함하는 객체 배열을 지정합니다

사용법

priorities?: [
{
id: number,
label: string,
hotkey?: string,
color?: string,
},
{ ... } // more priorities items
];

파라미터

priorities 속성은 우선순위 객체 배열을 나타냅니다. 각 객체는 다음 파라미터를 포함합니다:

  • id - (필수) 우선순위 ID
  • label - (필수) 우선순위 레이블
  • hotkey - (선택 사항) 우선순위를 적용하기 위한 사용자 정의 키보드 단축키 이름. 사용자 정의 단축키 조합을 정의하려면 아래 예제와 같이 사용자 정의 이벤트를 처리해야 합니다
  • color - (선택 사항) 우선순위 색상
정보

color 파라미터가 지정되지 않으면 위젯은 다음 기본 색상 중 하나를 적용합니다:

"#ff5252" "#ffc975" "#0ab169" "#607D8B" "#00C7B5"

"#03A9F4" "#9575CD" "#F06292" "#FF9800"

기본 config

const priorities: [
{
id: 1,
label: "High",
color: "#ff5252",
hotkey: "Alt+1"
},
{
id: 2,
label: "Medium",
color: "#ffc975",
hotkey: "Alt+2"
},
{
id: 3,
label: "Low",
color: "#0ab169",
hotkey: "Alt+3"
},
];

예제

const { ToDo } = todo;

const tasks = [ ... ];
const users = [ ... ];
const projects = [ ... ];

const priorities = [
{
id: 1,
label: "Critical",
color: "#f33",
},
{
id: 2,
label: "Major",
color: "rgba(255, 225, 0, 1)",
},
{
id: 3,
label: "Normal",
color: "hsla(170, 100%, 40%, 1)",
},
{
id: 4,
label: "Minor",
hotkey: "Alt+M", // "Alt+M" 조합을 정의하기 위해 "keydown" 이벤트를 처리합니다
},
];

const list = new ToDo ("#root", {
tasks,
users,
projects,
priorities
});

// 단축키 "Alt+M"에 대한 사용자 정의 이벤트 핸들러
document.addEventListener("keydown", event => {
if (event.altKey && event.key.toLocaleLowerCase() === "m") {
list.eachSelected(id => {
list.updateTask({
id,
task: { priority: 4 }
});
});
}
});

관련 문서:

관련 예제: To do list. 우선순위 설정을 위한 사용자 정의 단축키