|
58 | 58 | <td> |
59 | 59 | <a href="{{ call('PluginJamf' ~ data.jamf_type ~ '::getJamfDeviceURL', [data.jamf_items_id]) }}">{{ data.name }}</a> |
60 | 60 | </td> |
61 | | - <td>{{ data.type }}</td> |
| 61 | + <td> |
| 62 | + {% if supported_glpi_types[data.jamf_type]|length > 0 %} |
| 63 | + {{ fields.dropdownArrayField('glpi_type', data.type, supported_glpi_types[data.jamf_type], null, { |
| 64 | + no_label: true, |
| 65 | + full_width: true, |
| 66 | + }) }} |
| 67 | + {% else %} |
| 68 | + {{ data.type|itemtype_name }} |
| 69 | + {% endif %} |
| 70 | + </td> |
62 | 71 | <td>{{ data.jamf_type }}</td> |
63 | 72 | <td class="{{ data.udid is empty ? 'font-italic' : '' }}"> |
64 | 73 | {{ data.udid is not empty ? data.udid : _x('message', 'Not collected during discovery', 'jamf') }} |
65 | 74 | </td> |
66 | 75 | <td>{{ data.date_discover|formatted_datetime }}</td> |
67 | 76 | <td> |
68 | | - {{ fields.dropdownField(data.type, 'items_id', data.guessed_item, null, { |
69 | | - no_label: true, |
70 | | - full_width: true, |
71 | | - used: linked[data.type]|default([])|column('items_id') |
72 | | - }) }} |
| 77 | + {% for glpi_type in supported_glpi_types[data.jamf_type] %} |
| 78 | + <span class="{{ glpi_type != data.type ? 'd-none' : '' }}" data-itemtype="{{ glpi_type }}"> |
| 79 | + {{ fields.dropdownField(glpi_type, 'items_id', data.guessed_item[glpi_type], null, { |
| 80 | + no_label: true, |
| 81 | + full_width: true, |
| 82 | + used: linked[glpi_type]|default([])|column('items_id'), |
| 83 | + }) }} |
| 84 | + </span> |
| 85 | + {% endfor %} |
73 | 86 | </td> |
74 | 87 | </tr> |
75 | 88 | {% endfor %} |
|
93 | 106 | for (let i = 1; i < row_count; i++) { |
94 | 107 | const row = table.rows[i]; |
95 | 108 | const jamf_id = row.cells[0].innerText; |
96 | | - const itemtype = row.cells[2].innerText; |
| 109 | + const itemtype = $(row.cells[2]).find('select')[0].value; |
97 | 110 | const jamf_type = row.cells[3].innerText; |
98 | | - const glpi_sel = $(row.cells[6]).find('select')[0]; |
| 111 | + const glpi_sel = $(row.cells[6]).find('span[data-itemtype]:not(.d-none) select')[0]; |
99 | 112 | const glpi_id = glpi_sel.value; |
100 | 113 | if (glpi_id && glpi_id > 0) { |
101 | | - data = []; |
102 | 114 | post_data[glpi_id] = {'itemtype': itemtype, 'jamf_id': jamf_id, 'jamf_type': jamf_type}; |
103 | 115 | } |
104 | 116 | } |
|
115 | 127 | } |
116 | 128 | }); |
117 | 129 | } |
| 130 | + $('select[name="glpi_type"]').on('change', (e) => { |
| 131 | + const selection = $(e.target).val(); |
| 132 | + $(e.target).closest('tr').find('span[data-itemtype]').addClass('d-none'); |
| 133 | + $(e.target).closest('tr').find('span[data-itemtype="' + selection + '"]').removeClass('d-none'); |
| 134 | + }); |
118 | 135 | </script> |
119 | 136 | </div> |
120 | 137 | </form> |
0 commit comments