package com.zhangmeng.online.exam.ui.components;

import com.zhangmeng.online.exam.ui.api.form.base.Form;
import com.zhangmeng.online.exam.ui.controller.PermissionChooseController;
import javafx.fxml.FXMLLoader;

import java.io.IOException;
import java.util.Map;

/**
 * @author zm
 * @date 2025/4/10 11:13
 * @version: 1.0
 */
public class PermissionChooseComponent extends Form {

    private PermissionChooseController controller;

    private Map<String, Object> context;

    public Map<String, Object> getContext() {
        return context;
    }

    public void setContext(Map<String, Object> context) {
        this.context = context;
    }

    public PermissionChooseController getPermissionChooseController() {
        return controller;
    }

    public PermissionChooseComponent(Map<String, Object> context) {
        this.context = context;
        try {
            FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/permission-choose.fxml"));
            this.getChildren().add(fxmlLoader.load());
            this.controller = fxmlLoader.getController();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public void setController(PermissionChooseController controller) {
        this.controller = controller;
    }
}
