diff --git a/src/DependencyInjection/FlagbitTableAttributeExtension.php b/src/DependencyInjection/FlagbitTableAttributeExtension.php
index 77149ce..99c6e18 100644
--- a/src/DependencyInjection/FlagbitTableAttributeExtension.php
+++ b/src/DependencyInjection/FlagbitTableAttributeExtension.php
@@ -33,5 +33,6 @@ public function load(array $configs, ContainerBuilder $container)
$loader->load('query_builders.xml');
$loader->load('factories.xml');
$loader->load('doctrine.xml');
+ $loader->load('copiers.xml');
}
}
diff --git a/src/Resources/config/copiers.xml b/src/Resources/config/copiers.xml
new file mode 100644
index 0000000..cc41207
--- /dev/null
+++ b/src/Resources/config/copiers.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+ flagbit_catalog_table
+
+
+ flagbit_catalog_table
+
+
+
+
+
diff --git a/src/Resources/public/js/inittable.js b/src/Resources/public/js/inittable.js
index fa866cb..82d7ed9 100644
--- a/src/Resources/public/js/inittable.js
+++ b/src/Resources/public/js/inittable.js
@@ -3,7 +3,7 @@ define(
function ($, _) {
'use strict';
return {
- init: function ($target, columns) {
+ init: function ($target, columns, editMode) {
var $headerRow = $target.find('thead tr');
if($headerRow[0].innerHTML && $headerRow[0].innerHTML.length != 0){
@@ -39,7 +39,7 @@ define(
htmlColumns.push(this.createColumn(column, value));
}.bind(this));
- $tbody.append(this.createRow(htmlColumns));
+ $tbody.append(this.createRow(htmlColumns, editMode));
}.bind(this));
},
createColumn: function (column, value) {
@@ -48,13 +48,18 @@ define(
return td;
},
- createRow: function (htmlColumns) {
+ createRow: function (htmlColumns, editMode) {
var row = $('
');
row.append($(' | '));
_.each(htmlColumns, function (htmlColumn) {
row.append(htmlColumn);
});
- row.append($(' | '));
+
+ if (editMode === 'view') {
+ row.append($(' | '));
+ } else {
+ row.append($(' | '));
+ }
return row;
},
diff --git a/src/Resources/public/js/product/field/table-field.js b/src/Resources/public/js/product/field/table-field.js
index 54ba791..0689470 100644
--- a/src/Resources/public/js/product/field/table-field.js
+++ b/src/Resources/public/js/product/field/table-field.js
@@ -45,7 +45,7 @@ define([
var column = this.convertBackendItem(value);
this.columns[column.id] = column;
}.bind(this));
- initTable.init(this.$('.flagbit-table-attribute'), this.columns);
+ initTable.init(this.$('.flagbit-table-attribute'), this.columns, this.getEditMode());
// initialize dran & drop sorting
this.$('.flagbit-table-values tbody').sortable({
handle: ".handle",
@@ -107,7 +107,8 @@ define([
text: i18n.getLabel(item.labels, UserContext.get('catalogLocale'), item.code),
config: item.type_config,
type: item.type,
- func: this.createColumnFunctions(item)
+ func: this.createColumnFunctions(item),
+ editMode: this.getEditMode()
};
},
createColumnFunctions: function(item) {
@@ -127,10 +128,10 @@ define([
switch (item.type) {
case "text":
- fieldTemplate = "";
+ fieldTemplate = "/>";
break;
case "number":
- fieldTemplate = "' />";
+ fieldTemplate = "' <%= column.editMode === 'view' ? 'disabled' : '' %>/>";
if ('is_decimal' in item.type_config && item.type_config.is_decimal === true) {
parser = function (td) {
return parseFloat($('input', td).val());
@@ -142,7 +143,7 @@ define([
}
break;
case "select":
- fieldTemplate = "";
+ fieldTemplate = "/>";
parser = function (td) {
var option = $('input', td).select2('data');
@@ -174,7 +175,7 @@ define([
}.bind(this);
break;
case "select_from_url":
- fieldTemplate = "";
+ fieldTemplate = "/>";
parser = function (td) {
var option = $('input', td).select2('data');
diff --git a/src/Resources/public/templates/product/field/table.html b/src/Resources/public/templates/product/field/table.html
index 8420927..6005a83 100644
--- a/src/Resources/public/templates/product/field/table.html
+++ b/src/Resources/public/templates/product/field/table.html
@@ -1,6 +1,8 @@
-
+ <% if(editMode === 'edit') { %>
+
+ <% } %>