Skip to content

Commit 4609791

Browse files
committed
icons updated in ui
1 parent c6c5b66 commit 4609791

File tree

3 files changed

+35
-21
lines changed

3 files changed

+35
-21
lines changed

app/controllers/miq_ae_class_controller.rb

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require "rexml/document"
2+
require 'byebug'
23
class MiqAeClassController < ApplicationController
34
include MiqAeClassHelper
45
include AutomateTreeHelper
@@ -1456,17 +1457,22 @@ def field_select
14561457

14571458
# AJAX driven routine to select a classification entry
14581459
def field_accept
1460+
# byebug
14591461
assert_privileges('miq_ae_field_edit')
14601462
fields_get_form_vars
14611463
@changed = (@edit[:new] != @edit[:current])
14621464
@combo_xml = build_type_options
14631465
@dtype_combo_xml = build_dtype_options
1464-
render :update do |page|
1465-
page << javascript_prologue
1466-
page.replace("class_fields_div", :partial => "class_fields")
1467-
page << javascript_for_miq_button_visibility(@changed)
1468-
page << "miqSparkle(false);"
1469-
end
1466+
# render :update do |page|
1467+
# page << javascript_prologue
1468+
# page.replace("class_fields_div", :partial => "class_fields")
1469+
# page << javascript_for_miq_button_visibility(@changed)
1470+
# page << "miqSparkle(false);"
1471+
# end
1472+
render :json => {
1473+
:message => 'Accepted',
1474+
:data => {:icons => [ae_field_fonticon(params[:aetype]), ae_field_fonticon(params[:datatype])]}
1475+
}
14701476
end
14711477

14721478
# AJAX driven routine to delete a classification entry
@@ -2390,18 +2396,20 @@ def fields_get_form_vars
23902396
end
23912397
end
23922398
elsif params[:button] == "accept"
2393-
if session[:field_data][:name].blank? || session[:field_data][:aetype].blank?
2394-
field = session[:field_data][:name].blank? ? "Name" : "Type"
2395-
field += " and Type" if field == "Name" && session[:field_data][:aetype].blank?
2396-
add_flash(_("%{field} is required") % {:field => field}, :error)
2397-
return
2398-
end
2399+
# if session[:field_data][:name].blank? || session[:field_data][:aetype].blank?
2400+
# field = session[:field_data][:name].blank? ? "Name" : "Type"
2401+
# field += " and Type" if field == "Name" && session[:field_data][:aetype].blank?
2402+
# add_flash(_("%{field} is required") % {:field => field}, :error)
2403+
# return
2404+
# end
23992405
new_fields = {}
24002406
field_attributes.each do |field_attribute|
2401-
new_fields[field_attribute] = @edit[:new_field][field_attribute.to_sym]
2407+
# new_fields[field_attribute] = @edit[:new_field][field_attribute.to_sym]
2408+
# new_fields[field_attribute] = params[:field][field_attribute.to_sym]
2409+
new_fields[field_attribute] = params[field_attribute.to_sym]
24022410
end
24032411
@edit[:new][:fields].push(new_fields)
2404-
@edit[:new_field] = session[:field_data] = {}
2412+
# @edit[:new_field] = session[:field_data] = {}
24052413
end
24062414
end
24072415

app/javascript/components/data-tables/datastore/class-fields-editor.jsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export const ClassFieldsEditor = (props) => {
1515

1616
const fieldData = createEditableRows(initialData);
1717

18+
debugger
19+
1820
const transformedRows = () => {
1921
const rowItems = [];
2022
const headers = schemaHeaders(true);
@@ -109,12 +111,12 @@ export const ClassFieldsEditor = (props) => {
109111
</div>
110112
);
111113

112-
const formatFieldValues = (field, id) => {
114+
const formatFieldValues = (field, id, data = {}) => {
113115
if (!field || typeof field !== 'object') return [];
114116

115117
const row = {
116118
id: (field.id || id).toString(),
117-
name: { text: field.name, icon: field.icons },
119+
name: { text: field.name, icon: data.icons || [] },
118120
aetype: { text: field.aetype },
119121
datatype: { text: field.datatype },
120122
default_value: { text: field.default_value || '' },
@@ -149,7 +151,6 @@ export const ClassFieldsEditor = (props) => {
149151

150152
const onModalSubmit = (values) => {
151153
const isEdit = state.selectedRowId !== undefined;
152-
const data = formatFieldValues(values, isEdit ? state.selectedRowId : state.rows.length);
153154

154155
const updateState = (newData) => {
155156
setState((prevState) => ({
@@ -162,10 +163,14 @@ export const ClassFieldsEditor = (props) => {
162163
};
163164

164165
if (isEdit) {
166+
const data = formatFieldValues(values, state.selectedRowId);
165167
updateState(data);
166168
} else {
167169
http.post(`/miq_ae_class/field_accept?button=accept`, values, { skipErrors: [400] })
168-
.then(() => updateState(data))
170+
.then((response) => {
171+
const data = formatFieldValues(values, state.rows.length, response.data);
172+
updateState(data);
173+
})
169174
.catch((error) => {
170175
console.error('Failed to save new field:', error);
171176
});

app/javascript/components/data-tables/datastore/modal-form.schema.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { transformSelectOptions, handleSchemaFieldChange } from './helper';
33

44
const createClassFieldsSchema = (aeTypeOptions, dTypeOptions, selectedRowId, schemaField = {}) => {
55
const classField = schemaField;
6+
console.log("Classfield -- ", classField);
67
// const getFieldName = (fname, index) =>
78
// (typeof index !== 'undefined' ? `fields_${fname}_${index}` : `field_${fname}`);
89

@@ -24,10 +25,10 @@ const createClassFieldsSchema = (aeTypeOptions, dTypeOptions, selectedRowId, sch
2425
classField
2526
&& typeof classField === 'object'
2627
&& Object.keys(classField).length > 0
27-
&& classField.Name
28-
&& 'icon' in classField.Name
28+
&& classField.name
29+
&& 'icon' in classField.name
2930
) {
30-
return classField.Name.icon[index];
31+
return classField.name.icon[index];
3132
}
3233
return '';
3334
};

0 commit comments

Comments
 (0)