cloud-ide-element 1.0.65 → 1.0.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/cloud-ide-element.mjs +100 -15
- package/fesm2022/cloud-ide-element.mjs.map +1 -1
- package/index.d.ts +30 -0
- package/package.json +1 -1
|
@@ -5567,10 +5567,17 @@ class CideEleDataGridComponent {
|
|
|
5567
5567
|
const baseOrder = Math.min(...this.displayedData.map(item => this.getItemOrder(item)));
|
|
5568
5568
|
const newOrderValue = baseOrder + index;
|
|
5569
5569
|
currentEntry.newPosition = newOrderValue;
|
|
5570
|
+
// IMPORTANT: Update the actual sequence value in the item itself
|
|
5571
|
+
this.setNestedValue(item, dragDropConfig.orderField, newOrderValue);
|
|
5570
5572
|
}
|
|
5571
5573
|
else {
|
|
5572
5574
|
// Fallback to index-based position
|
|
5573
|
-
|
|
5575
|
+
const newOrderValue = index + 1;
|
|
5576
|
+
currentEntry.newPosition = newOrderValue;
|
|
5577
|
+
// Update the actual sequence value in the item itself
|
|
5578
|
+
if (dragDropConfig?.orderField) {
|
|
5579
|
+
this.setNestedValue(item, dragDropConfig.orderField, newOrderValue);
|
|
5580
|
+
}
|
|
5574
5581
|
}
|
|
5575
5582
|
this.rowOrderMap.set(itemId, currentEntry);
|
|
5576
5583
|
}
|
|
@@ -5658,6 +5665,23 @@ class CideEleDataGridComponent {
|
|
|
5658
5665
|
.sort((a, b) => a.newPosition - b.newPosition)
|
|
5659
5666
|
.map(orderedItem => orderedItem.item);
|
|
5660
5667
|
}
|
|
5668
|
+
/**
|
|
5669
|
+
* Get only the items that have actually changed order
|
|
5670
|
+
*/
|
|
5671
|
+
getChangedOrders() {
|
|
5672
|
+
const changedItems = [];
|
|
5673
|
+
// Get the full dataset from the config
|
|
5674
|
+
const fullData = this.mergedConfig().data || [];
|
|
5675
|
+
// Check each item to see if its position has changed
|
|
5676
|
+
this.rowOrderMap.forEach((orderInfo, itemId) => {
|
|
5677
|
+
const item = fullData.find(dataItem => this.getItemId(dataItem) === itemId);
|
|
5678
|
+
if (item && orderInfo.oldPosition !== orderInfo.newPosition) {
|
|
5679
|
+
changedItems.push(item);
|
|
5680
|
+
console.log('🔍 Item changed order:', itemId, 'from', orderInfo.oldPosition, 'to', orderInfo.newPosition);
|
|
5681
|
+
}
|
|
5682
|
+
});
|
|
5683
|
+
return changedItems;
|
|
5684
|
+
}
|
|
5661
5685
|
/**
|
|
5662
5686
|
* Update local data order for visual reordering (LOCAL ONLY)
|
|
5663
5687
|
*/
|
|
@@ -5709,25 +5733,32 @@ class CideEleDataGridComponent {
|
|
|
5709
5733
|
console.log('🔍 Reset clicked, row order map reset locally, visual display reverted');
|
|
5710
5734
|
}
|
|
5711
5735
|
else if (action.key === 'save-order') {
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5736
|
+
// Check if there are any actual changes before proceeding
|
|
5737
|
+
const hasActualChanges = this.checkIfOrderChanged();
|
|
5738
|
+
if (!hasActualChanges) {
|
|
5739
|
+
console.log('🔍 No actual order changes detected, skipping save');
|
|
5740
|
+
this.hasOrderChanged.set(false);
|
|
5741
|
+
return;
|
|
5742
|
+
}
|
|
5743
|
+
// Get only the changed orders and emit them BEFORE clearing local data
|
|
5744
|
+
const changedOrders = this.getChangedOrders();
|
|
5745
|
+
if (changedOrders.length > 0) {
|
|
5746
|
+
console.log('🔍 Emitting rowReorder event with changed orders only:', changedOrders);
|
|
5747
|
+
console.log('🔍 Number of changed records:', changedOrders.length, 'out of', this.getCurrentOrderFromMap().length, 'total records');
|
|
5722
5748
|
// Use the expected GridEvent structure for rowReorder
|
|
5723
5749
|
this.emitEvent('rowReorder', {
|
|
5724
|
-
sourceItem:
|
|
5750
|
+
sourceItem: changedOrders[0], // First changed item as source
|
|
5725
5751
|
sourceIndex: 0, // First position as source
|
|
5726
|
-
targetItem:
|
|
5727
|
-
targetIndex:
|
|
5728
|
-
newOrder:
|
|
5752
|
+
targetItem: changedOrders[changedOrders.length - 1], // Last changed item as target
|
|
5753
|
+
targetIndex: changedOrders.length - 1, // Last position as target
|
|
5754
|
+
newOrder: changedOrders, // Only the records whose order actually changed
|
|
5755
|
+
allOrders: this.getCurrentOrderFromMap() // Complete order for reference
|
|
5729
5756
|
});
|
|
5730
5757
|
}
|
|
5758
|
+
// DON'T clear the local data or reset the order map here
|
|
5759
|
+
// Let the parent component handle the data refresh after API call
|
|
5760
|
+
// The local data will be cleared when new data arrives via ngOnChanges
|
|
5761
|
+
console.log('🔍 Save clicked, rowReorder event emitted, preserving local data until API response');
|
|
5731
5762
|
}
|
|
5732
5763
|
if (this.actionHandlers[action.onClick]) {
|
|
5733
5764
|
this.actionHandlers[action.onClick](item, action);
|
|
@@ -5753,6 +5784,60 @@ class CideEleDataGridComponent {
|
|
|
5753
5784
|
return current && typeof current === 'object' ? current[key] : undefined;
|
|
5754
5785
|
}, obj);
|
|
5755
5786
|
}
|
|
5787
|
+
/**
|
|
5788
|
+
* Set a nested value in an object using dot notation
|
|
5789
|
+
* @param obj The object to modify
|
|
5790
|
+
* @param path The dot notation path (e.g., 'contact.email')
|
|
5791
|
+
* @param value The value to set
|
|
5792
|
+
* @example
|
|
5793
|
+
* const obj = { contact: { email: 'old@example.com' } };
|
|
5794
|
+
* setNestedValue(obj, 'contact.email', 'new@example.com');
|
|
5795
|
+
* // obj.contact.email === 'new@example.com'
|
|
5796
|
+
*/
|
|
5797
|
+
setNestedValue(obj, path, value) {
|
|
5798
|
+
const keys = path.split('.');
|
|
5799
|
+
const lastKey = keys.pop();
|
|
5800
|
+
const target = keys.reduce((current, key) => {
|
|
5801
|
+
if (current && typeof current === 'object') {
|
|
5802
|
+
if (!current[key]) {
|
|
5803
|
+
current[key] = {};
|
|
5804
|
+
}
|
|
5805
|
+
return current[key];
|
|
5806
|
+
}
|
|
5807
|
+
return undefined;
|
|
5808
|
+
}, obj);
|
|
5809
|
+
if (target && typeof target === 'object') {
|
|
5810
|
+
target[lastKey] = value;
|
|
5811
|
+
}
|
|
5812
|
+
}
|
|
5813
|
+
/**
|
|
5814
|
+
* Compare two order arrays to check if they are different
|
|
5815
|
+
* This method can be used by parent components to check if order has actually changed
|
|
5816
|
+
* @param currentOrder Current order array
|
|
5817
|
+
* @param originalOrder Original order array
|
|
5818
|
+
* @returns true if orders are different, false if they are the same
|
|
5819
|
+
*/
|
|
5820
|
+
compareOrders(currentOrder, originalOrder) {
|
|
5821
|
+
console.log('🔍 DataGrid: Comparing orders - current length:', currentOrder.length, 'original length:', originalOrder.length);
|
|
5822
|
+
// If lengths are different, there are changes
|
|
5823
|
+
if (currentOrder.length !== originalOrder.length) {
|
|
5824
|
+
console.log('🔍 DataGrid: Lengths are different, returning true');
|
|
5825
|
+
return true;
|
|
5826
|
+
}
|
|
5827
|
+
// Compare the order of items by their IDs (not just their sequence values)
|
|
5828
|
+
// This will detect if items have been reordered even if sequence values are the same
|
|
5829
|
+
for (let i = 0; i < currentOrder.length; i++) {
|
|
5830
|
+
const currentItem = currentOrder[i];
|
|
5831
|
+
const originalItem = originalOrder[i];
|
|
5832
|
+
console.log('🔍 DataGrid: Position', i, '- Current ID:', currentItem.id, 'Original ID:', originalItem.id);
|
|
5833
|
+
if (currentItem.id !== originalItem.id) {
|
|
5834
|
+
console.log('🔍 DataGrid: Different item at position', i, 'returning true');
|
|
5835
|
+
return true;
|
|
5836
|
+
}
|
|
5837
|
+
}
|
|
5838
|
+
console.log('🔍 DataGrid: No differences found, returning false');
|
|
5839
|
+
return false;
|
|
5840
|
+
}
|
|
5756
5841
|
formatValue(value, column) {
|
|
5757
5842
|
if (column.formatter) {
|
|
5758
5843
|
if (column.formatter.type === 'custom' && column.formatter.customFunction) {
|