Skip to content

Commit

Permalink
new_menuForm
Browse files Browse the repository at this point in the history
  • Loading branch information
sooobee committed May 30, 2023
1 parent e39486a commit d1efd17
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
18 changes: 9 additions & 9 deletions adm/menu_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,27 @@ function() {

});

// 다시 click으로 변경
$(document).on("click", "#add_manual", function() {
var me_name = $.trim($("#me_name").val());
var me_link = $.trim($("#me_link").val());

add_menu_list(me_name, me_link, "<?php echo $code; ?>");
});

$(document).on("checklist", ".add_select", function() {
$(document).on("click", ".add_select", function() {
var me_name = $.trim($(this).siblings("input[name='subject[]']").val());
var me_link = $.trim($(this).siblings("input[name='link[]']").val());

add_menu_list(me_name, me_link, "<?php echo $code; ?>");
});
});

// 추가된 메뉴들 여기에 표시
// 선택 누르면 이 함수가 실행
function add_menu_list(name, link, code) {
var $menulist = $("#menulist", opener.document);
var ms = new Date().getTime();
var sub_menu_class;

<?php if ($new == 'new') { ?>
sub_menu_class = " class=\"td_category\"";
<?php } else { ?>
Expand Down Expand Up @@ -181,19 +181,19 @@ function add_menu_list(name, link, code) {

if ($menu_last.length > 0) {
$menu_last.after(list);
} else {
if ($menulist.find("#empty_menu_list").length > 0)
$menulist.find("#empty_menu_list").remove();
} else { // 리스트가 없을 때(추가한 게 없을 때)
if ($menulist.find("#empty_menu_list").length > 0) // 이미 추가된 게 있으면
$menulist.find("#empty_menu_list").remove(); // 메뉴리스트가 비지 않았다

$menulist.find("table tbody").append(list);
$menulist.find("table tbody").append(list); // 리스트를 붙혀
}

$menulist.find("tr.menu_list").each(function(index) {
$(this).removeClass("bg0 bg1")
.addClass("bg" + (index % 2));
});

//window.close();
loacation.replace(location.bref);
}
</script>

Expand Down
30 changes: 26 additions & 4 deletions adm/menu_form_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,39 @@
<td class="td_mngsmall">
<input type="hidden" name="subject[]" value="<?php echo preg_replace('/[\'\"]/', '', $row['subject']); ?>">
<input type="hidden" name="link[]" value="<?php echo $link; ?>">
<input type="checkbox" id="myCheckbox" class="add_select_check btn btn_03"><span class="sound_only" onclick="toggleCheckbox()"> <?php echo $row['subject']?></span> </input>
<input type="checkbox" id="myCheckbox" class = "add_select" name="subject[]" value="<?php echo $row['subject'];?>"><span class="sound_only" onclick="toggleCheckbox()"></span> </input>

</td>
</tr>

<script>
// 체크박스를 클릭하면 실행되는 함수
function toggleCheckbox() {
var checkbox = document.getElementById("myCheckbox");
checkbox.checked = !checkbox.checked;

// 선택된 게시판 정보를 가져옴
var subject = checkbox.parentNode.querySelector('input[name="subject[]"]').value;
var link = checkbox.parentNode.querySelector('input[name="link[]"]').value;

// 선택된 게시판 정보를 배열에 추가
var menu = {
subject: subject,
link: link
};
<?php if (!empty($menu_list)): ?>
<?php foreach ($menu_list as $menu_item): ?>
<?php
// 기존에 이미 선택한 게시판인지 확인 후 추가
?>
<?php endforeach; ?>
<?php endif; ?>
<?php
// 추가된 게시판 정보를 $menu_list에 저장 (PHP 변수로 전달하기 위해 AJAX 등을 사용해야 함)
?>
}
</script>
</script>


<?php } ?>

Expand All @@ -102,8 +125,7 @@ function toggleCheckbox() {

<div class="btn_win02 btn_win">
<button type="button" class="btn_02 btn" onclick="window.close();">창닫기</button>
<button type="button" class="add_select btn btn_03"><span class="sound_only"><?php echo $row['subject']; ?> </span>선택
</button>

</div>

<?php } else { ?>
Expand Down

6 comments on commit d1efd17

@tleunwlp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 실행해봤는데 체크박스 선택해서 하나하나 메뉴 테이블에 추가하는 기능은 실행되지만, 메뉴테이블에서 삭제했을 시 삭제가 한번에 돼요..!

@sooobee
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

헉 왜 그럴까요 ㅜㅜ

@Jiny0ng
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메뉴테이블을 저장하는 리스트의 문제가 있는것 같아요
삭제버튼을 pop으로 변경해보는건 어떨까요?

@kkigomi
Copy link
Contributor

@kkigomi kkigomi commented on d1efd17 May 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMG_6035
IMG_6036
IMG_6037
IMG_6038

@sooobee @sieun0 @Jiny0ng

커밋, PR 테스트인지 장난인지, 오픈소스에 PR 보내는게 학교 과제인지 모르겠지만 저장소를 구독하고있는 사람들에게 이렇게 메일로 모두 전송되고 영구적으로 남을수있으니 주의해주세요.

@sooobee
Copy link
Author

@sooobee sooobee commented on d1efd17 May 30, 2023 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kkigomi
Copy link
Contributor

@kkigomi kkigomi commented on d1efd17 May 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 죄송합니다. 깃허브 사용법을 잘 몰랐습니다. 학교 과제로 branch를 파서 따로 수정해보고 있습니다. 저희끼리 코드리뷰를 진행하고 싶은데, 혹시 공공적으로 메일이 가지 않는 방법이 있을까요?

PR을 꼭 보낸 후에 해야하는게 아니라면 해당 저장소 내에서 하시면 되겠네요. sooobee님의 저장소에 커밋이 있으니 해당 커밋에서 리뷰하시면 되겠죠.

sooobee@d1efd17

Please sign in to comment.