package jp.co.y_net.amm.page;

import jp.co.y_net.amm.AppSession;
import jp.co.y_net.amm.common.AppLogger;

import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;



public class MenuPage extends CommonFrameA{
    
    /**
     * ページ利用可能Roleの設定
     */
    @Override
    protected boolean okUser() {
        return false
                || AppSession.isLogin(AppSession.LoginUser.Role.USER)
                || AppSession.isLogin(AppSession.LoginUser.Role.LEADER)
                || AppSession.isLogin(AppSession.LoginUser.Role.ADMIN)
                || AppSession.isLogin(AppSession.LoginUser.Role.DEV)
                ;
    }
    public MenuPage() {
        
	    /*
	     * 機関会員メニュー
	     */
	    WebMarkupContainer contUser = new WebMarkupContainer("contUser"){
            @Override
            public boolean isVisible() {
                return AppSession.isLogin(AppSession.LoginUser.Role.USER);
            }
	    };
	    add(contUser);
	    /* ・会員情報の編集 */
	    contUser.add(new Link<MemberDetailPage>("goMemberDetail"){
            @Override
            public void onClick() {
                MemberDetailPage page = new MemberDetailPage(AppSession.getLoginUserId());
                setResponsePage(page);
            }
	    });
	    
	    /*
         * 機関管理者メニュー
         */
	    WebMarkupContainer contLeader = new WebMarkupContainer("contLeader"){
            @Override
            public boolean isVisible() {
                return AppSession.isLogin(AppSession.LoginUser.Role.LEADER);
            }
        };
	    add(contLeader);
	    contLeader.add(new Link<MemberListPage>("goMemberList") {
            @Override
            public void onClick() {
                MemberListPage page = new MemberListPage(AppSession.getLoginOrgId());
                setResponsePage(page);
            }
	    });
	    contLeader.add(new Link<OrgDetailPage>("goOrgDetail") {
            @Override
            public void onClick() {
                OrgDetailPage page = new OrgDetailPage(AppSession.getLoginOrgId());
                setResponsePage(page);
            }
        });
	    
	    /*
         * 運営管理者メニュー
         */
        WebMarkupContainer contAdmin = new WebMarkupContainer("contAdmin"){
            @Override
            public boolean isVisible() {
                return AppSession.isLogin(AppSession.LoginUser.Role.ADMIN);
            }
        };
        add(contAdmin);
        contAdmin.add(new Link<OrgEntryListPage>("goOrgEntryList") {
            @Override
            public void onClick() {
                OrgEntryListPage page = new OrgEntryListPage();
                setResponsePage(page);
            }
        });
        contAdmin.add(new Link<OrgMemberListPage>("goOrgMemberList") {
            @Override
            public void onClick() {
                OrgMemberListPage page = new OrgMemberListPage();
                setResponsePage(page);
            }
        });
        contAdmin.add(new BookmarkablePageLink<InfoListPage>("ogInfoList", InfoListPage.class));

        /*
         * システム開発者メニュー
         */
        WebMarkupContainer contDev = new WebMarkupContainer("contDev"){
            @Override
            public boolean isVisible() {
                return AppLogger.isDebug();
            }
        };
        add(contDev);
        contDev.add(new BookmarkablePageLink<DashboardPage>("goDashboard", DashboardPage.class));
	    
	    
    }
}
