그룹에 속하는 인원인가 아닌가?
•
해당 문제를 해결할 수 있는 함수를 아래와 같이 추가하였습니다.
•
해당 그룹이 아닌 사람이 들어오게 되면 플래너를 수정하거나 생성할수 없도록 특정 요소는 숨김처리 하였습니다.
window.onload = function() {
notGroupReadOnly();
}
function notGroupReadOnly() {
const group = [[${planner.travelGroup.participants}]]
const myId = [[${#authentication.name}]]
console.log('myId', myId)
console.log(group)
// !! => true, false 변환 위해 사용
const isTravelGroup = !!(group || []) // 1
.find((obj) => {
const userId = (obj.member || {}).userId || '' // 2
if (!userId) return false // 3
return userId === myId // 4
})
console.log('isTravelGroup', isTravelGroup)
// 여행그룹이 아닌 사람은 읽기전용
if (!isTravelGroup) {
// 읽기 전용
//$('input').prop('readonly', true);
// 안보이게
$('input').hide();
$('.todolistmod').hide();
$('.todolistdel').hide();
$('.actodomod').hide();
$('.actododel').hide();
$('.attodomod').hide();
$('.attododel').hide();
$('.bgtodomod').hide();
$('.bgtododel').hide();
$('.gntodomod').hide();
$('.gntododel').hide();
$('.trtodomod').hide();
$('.trtododel').hide();
$('.open').hide();
$('.add__card').hide();
$('#addDate').hide();
$('.chat').hide();
$('label').hide();
}
$('.card').off('click');
}
JavaScript
복사
결과