fixed channel create

This commit is contained in:
WolverinDEV 2019-06-22 12:39:09 +02:00
parent f74326c5fb
commit 7de5236491

View file

@ -75,19 +75,20 @@ namespace Modals {
function applyGeneralListener(connection: ConnectionHandler, properties: ChannelProperties, tag: JQuery, button: JQuery, channel: ChannelEntry | undefined) { function applyGeneralListener(connection: ConnectionHandler, properties: ChannelProperties, tag: JQuery, button: JQuery, channel: ChannelEntry | undefined) {
let updateButton = () => { let updateButton = () => {
if(tag.find(".input_error").length == 0) const status = tag.find(".input_error").length != 0;
button.removeAttr("disabled"); console.log("Disabled: %o", status);
else button.attr("disabled", "true"); button.prop("disabled", status);
}; };
tag.find(".channel_name").on('change keyup', function (this: HTMLInputElement) { {
properties.channel_name = this.value; const channel_name = tag.find(".channel_name");
tag.find(".channel_name").on('change keyup', function (this: HTMLInputElement) {
properties.channel_name = this.value;
$(this).removeClass("input_error"); channel_name.toggleClass("input_error", this.value.length < 1 || this.value.length > 40);
if(this.value.length < 1 || this.value.length > 40) updateButton();
$(this).addClass("input_error"); }).prop("disabled", channel && !connection.permissions.neededPermission(PermissionType.B_CHANNEL_MODIFY_NAME).granted(1));
updateButton(); }
}).prop("disabled", channel && !connection.permissions.neededPermission(PermissionType.B_CHANNEL_MODIFY_NAME).granted(1));
tag.find(".button-select-icon").on('click', event => { tag.find(".button-select-icon").on('click', event => {
Modals.spawnIconSelect(connection, id => { Modals.spawnIconSelect(connection, id => {
@ -100,17 +101,20 @@ namespace Modals {
}, channel ? channel.properties.channel_icon_id : 0); }, channel ? channel.properties.channel_icon_id : 0);
}); });
tag.find(".channel_password").change(function (this: HTMLInputElement) { {
properties.channel_flag_password = this.value.length != 0; const channel_password = tag.find(".channel_password");
if(properties.channel_flag_password) tag.find(".channel_password").change(function (this: HTMLInputElement) {
helpers.hashPassword(this.value).then(pass => properties.channel_password = pass); properties.channel_flag_password = this.value.length != 0;
if(properties.channel_flag_password)
helpers.hashPassword(this.value).then(pass => properties.channel_password = pass);
$(this).removeClass("input_error"); channel_password.removeClass("input_error");
if(!properties.channel_flag_password) if(!properties.channel_flag_password)
if(connection.permissions.neededPermission(PermissionType.B_CHANNEL_CREATE_MODIFY_WITH_FORCE_PASSWORD).granted(1)) if(connection.permissions.neededPermission(PermissionType.B_CHANNEL_CREATE_MODIFY_WITH_FORCE_PASSWORD).granted(1))
$(this).addClass("input_error"); channel_password.addClass("input_error");
updateButton(); updateButton();
}).prop("disabled", !connection.permissions.neededPermission(!channel ? PermissionType.B_CHANNEL_CREATE_WITH_PASSWORD : PermissionType.B_CHANNEL_MODIFY_PASSWORD).granted(1)); }).prop("disabled", !connection.permissions.neededPermission(!channel ? PermissionType.B_CHANNEL_CREATE_WITH_PASSWORD : PermissionType.B_CHANNEL_MODIFY_PASSWORD).granted(1));
}
tag.find(".channel_topic").change(function (this: HTMLInputElement) { tag.find(".channel_topic").change(function (this: HTMLInputElement) {
properties.channel_topic = this.value; properties.channel_topic = this.value;