@namespace Oqtane.Themes.OqtaneTheme
@inherits ModuleBase
@implements Oqtane.Interfaces.ISettingsControl
@inject ISettingService SettingService
@attribute [OqtaneIgnore]

<table class="table table-borderless">
    <tr>
        <td>
            <Label For="footer" ResourceKey="Footer" HelpText="Specify If A Footer Should Always Be Displayed In A Fixed Location At The Bottom Of The Browser Window">Display Fixed Footer?</Label>
        </td>
        <td>
            <select id="footer" class="form-control" @bind="@_footer">
                <option value="true">Yes</option>
                <option value="false">No</option>
            </select>
        </td>
    </tr>
</table>

@code {
    private string _footer = "false";

    protected override void OnInitialized()
    {
        try
        {
            _footer = SettingService.GetSetting(PageState.Page.Settings, GetType().Namespace + ":Footer", "false");
        }
        catch (Exception ex)
        {
            ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
        }
    }

    public async Task UpdateSettings()
    {
        try
        {
            var settings = PageState.Page.Settings;
            settings = SettingService.SetSetting(settings, GetType().Namespace + ":Footer", _footer);
            await SettingService.UpdatePageSettingsAsync(settings, PageState.Page.PageId);
        }
        catch (Exception ex)
        {
            ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
        }
    }
}
