let listPropertyAll function openAddPropertyNew() { pageselect('device-add-field-new-page'); createSelectNewProperty(listPropertyAll); resetFormNew(); } function createSelectNewProperty(propertyAllList) { let select = $('.selectNewProperty'); select.empty(); propertyAllList.forEach((item, index, array) => { if (!DevPropTableNew.columns(0).data()[0].find(elm => elm.devicePropertyKey === item.devicePropertyKey)) select.append(new Option(item.devicePropertyDescription, item.devicePropertyKey)); }); select.append(new Option("ПОЛЬЗОВАТЕЛЬСКОЕ ПОЛЕ", "")); } function getAllProperty(className) { $.ajax({ type: 'GET', contentType: 'application/json', url: '/api/refs/device/properties?className=' + className }) .done((data, textStatus, jqXHR) => { }) .fail((jqXHR, textStatus, errorThrown) => { console.log("ERROR : ", jqXHR.responseText); }) .always((data) => { console.log("***", data); listPropertyAll = data; }) } function resetFormNew() { $("#input11").val(''); $("#input21").val(''); $('#input11').prop('disabled', false); $(".selectNewProperty option").last().prop('selected',true); } function saveDevicePropertyFieldNew() { let keyField = document.getElementById("input11").value; let valueField = document.getElementById("input21").value; let descriptionField = $(".selectNewProperty option:selected").text(); DevPropTableNew.row.add( { "devicePropertyKey": keyField, "devicePropertyValue": valueField, "devicePropertyDescription": descriptionField } ).draw(); customHistory.back(); } function changeSelectNewProperty(data) { let value = data.value; $('#input11').val(data.value); if (value === '') $('#input11').prop('disabled', false); else $('#input11').prop('disabled', true); }