Skip to content

Commit 1f94ebe

Browse files
Air-PetrBen Thomson
authored andcommitted
Allow editing of migration file in "Confirm migration" popup in database table editor. (#282)
Credit to @Air-Petr. Refs: #279
1 parent e50640a commit 1f94ebe

File tree

11 files changed

+29
-13
lines changed

11 files changed

+29
-13
lines changed

assets/js/build-min.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ if(data.builderResponseData.operation!='delete'){$masterTabPane.find('input[name
155155
this.updateMasterTabIdAndTitle($masterTabPane,data.builderResponseData)
156156
this.unhideFormDeleteButton($masterTabPane)
157157
this.getTableList().fileList('markActive',data.builderResponseData.tabId)
158-
this.getIndexController().unchangeTab($masterTabPane)}
158+
this.getIndexController().unchangeTab($masterTabPane)
159+
this.updateTable(data.builderResponseData)}
159160
else{this.forceCloseTab($masterTabPane)}
160161
$.oc.builder.dataRegistry.clearCache(data.builderResponseData.pluginCode,'model-columns')}
161162
DatabaseTable.prototype.getTableList=function(){return $('#layout-side-panel form[data-content-id=database] [data-control=filelist]')}
@@ -178,6 +179,9 @@ tableObj.addRecord('bottom',true)
178179
tableObj.setRowValues(currentData.length-1,rowData)
179180
tableObj.addRecord('bottom',false)
180181
tableObj.deleteRecord()}
182+
DatabaseTable.prototype.updateTable=function(data){var tabsObject=this.getMasterTabsObject(),tabs=$('#builder-master-tabs').data('oc.tab'),tab=tabs.findByIdentifier(data.tabId)
183+
tabsObject.updateTab(tab,data.tableName,data.tab)
184+
this.onTableLoaded()}
181185
$.oc.builder.entityControllers.databaseTable=DatabaseTable;}(window.jQuery);+function($){"use strict";if($.oc.builder===undefined)
182186
$.oc.builder={}
183187
if($.oc.builder.entityControllers===undefined)

assets/js/builder.index.entity.databasetable.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@
218218

219219
this.getTableList().fileList('markActive', data.builderResponseData.tabId)
220220
this.getIndexController().unchangeTab($masterTabPane)
221+
222+
this.updateTable(data.builderResponseData)
221223
}
222224
else {
223225
this.forceCloseTab($masterTabPane)
@@ -295,6 +297,15 @@
295297
tableObj.deleteRecord()
296298
}
297299

300+
DatabaseTable.prototype.updateTable = function(data) {
301+
var tabsObject = this.getMasterTabsObject(),
302+
tabs = $('#builder-master-tabs').data('oc.tab'),
303+
tab = tabs.findByIdentifier(data.tabId)
304+
305+
tabsObject.updateTab(tab, data.tableName, data.tab)
306+
this.onTableLoaded()
307+
}
308+
298309
// REGISTRATION
299310
// ============================
300311

behaviors/IndexDatabaseTableOperations.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,21 @@ public function onDatabaseTableMigrationApply()
103103
$this->controller->widget->versionList->refreshActivePlugin()
104104
);
105105

106+
$widget = $this->makeBaseFormWidget($table);
107+
$this->vars['tableName'] = $table;
108+
106109
$result['builderResponseData'] = [
107110
'builderObjectName'=>$table,
108111
'tabId' => $this->getTabId($table),
109112
'tabTitle' => $table,
110113
'tableName' => $table,
111114
'operation' => $operation,
112-
'pluginCode' => $pluginCode->toCode()
115+
'pluginCode' => $pluginCode->toCode(),
116+
'tab' => $this->makePartial('tab', [
117+
'form' => $widget,
118+
'pluginCode' => $this->getPluginCode()->toCode(),
119+
'tableName' => $table
120+
])
113121
];
114122

115123
return $result;

classes/MigrationModel.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use ValidationException;
1212
use SystemException;
1313
use Exception;
14+
use Throwable;
1415

1516
/**
1617
* Manages plugin migrations
@@ -133,12 +134,12 @@ public function save($executeOnSave = true)
133134
VersionManager::instance()->updatePlugin($this->getPluginCodeObj()->toCode(), $this->version);
134135
}
135136
}
136-
catch (Exception $ex) {
137-
// Remove the script file, and rollback
137+
catch (Throwable $e) {
138+
// Remove the script file, and rollback
138139
// the version.yaml.
139140
$this->rollbackSaving($originalVersionData, $originalFileContents);
140141

141-
throw $ex;
142+
throw $e;
142143
}
143144

144145
$this->originalVersion = $this->version;

classes/migrationmodel/fields.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@ fields:
55
label: rainlab.builder::lang.migration.field_description
66
code:
77
label: rainlab.builder::lang.migration.field_code
8-
commentAbove: rainlab.builder::lang.migration.field_code_comment
98
type: codeeditor
109
language: php
11-
readOnly: true

lang/cs/lang.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,6 @@
573573
'field_version' => 'Verze',
574574
'field_description' => 'Popis migrace',
575575
'field_code' => 'Kód migrace',
576-
'field_code_comment' => 'Kód migrace je pouze pro čtení a slouží pouze pro náhled. Vlastní migraci můžete vytvořit v sekci Verze v levém menu.',
577576
'save_and_apply' => 'Uložit a aplikovat',
578577
'error_version_exists' => 'Tato verze migrace již existuje.',
579578
'error_script_filename_invalid' => 'The migration script file name can contain only Latin letters, digits and underscores. The name should start with a Latin letter and could not contain spaces.',

lang/en/lang.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,6 @@
636636
'field_version' => 'Version',
637637
'field_description' => 'Description',
638638
'field_code' => 'Code',
639-
'field_code_comment' => 'The migration code is read-only and for the preview purpose only. You can create custom migrations manually in the Versions section of the Builder.',
640639
'save_and_apply' => 'Save & Apply',
641640
'error_version_exists' => 'The migration version already exists.',
642641
'error_script_filename_invalid' => 'The migration script file name can contain only Latin letters, digits and underscores. The name should start with a Latin letter and could not contain spaces.',

lang/es/lang.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,6 @@
589589
'field_version' => 'Versión',
590590
'field_description' => 'Descripción',
591591
'field_code' => 'Code',
592-
'field_code_comment' => 'The migration code is read-only and for the preview purpose only. You can create custom migrations manually in the Versions section of the Builder.',
593592
'save_and_apply' => 'Salvar y Aplicar',
594593
'error_version_exists' => 'The migration version already exists.',
595594
'error_script_filename_invalid' => 'The migration script file name can contain only Latin letters, digits and underscores. The name should start with a Latin letter and could not contain spaces.',

lang/fa/lang.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,6 @@
574574
'field_version' => 'ویرایش',
575575
'field_description' => 'توضیحات',
576576
'field_code' => 'کد',
577-
'field_code_comment' => 'کد ساختار بانک اطلاعاتی فقط خواندنی و فقط جهت پیش نمایش می باشد. شما میتوانید ساختار بانک اطلاعاتی سفارشی را به صورت دستی در بخش ویرایش ها ایجاد نمایید.',
578577
'save_and_apply' => 'ذخیره و اعمال',
579578
'error_version_exists' => 'فایل ساختار بانک اطلاعاتی قبلا تعریف شده است.',
580579
'error_script_filename_invalid' => 'نام فایل ساختار بانک اطلاعاتی فقط میتواند حاوی حروف لاتین، اعداد و خط زیر باشد و با یک حرف لاتین بزرگ شروع شود.',

lang/nl/lang.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,6 @@
590590
'field_version' => 'Versie',
591591
'field_description' => 'Omschrijving',
592592
'field_code' => 'Code',
593-
'field_code_comment' => 'De migratie-code in alleen-lezen en alleen voor voorbeeldweergave. Je kan handmatig migraties aanmaken in het Versies onderdeel van Builder.',
594593
'save_and_apply' => 'Opslaan & toepassen',
595594
'error_version_exists' => 'De migratie-versie bestaat reeds.',
596595
'error_script_filename_invalid' => 'De bestandsnaam van de migratie kan alleen letters, getallen en underscores bevatten. De naam moet beginnen met een letter en mag geen spaties bevatten.',

0 commit comments

Comments
 (0)