1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-08 07:47:00 +02:00

Merge branch 'adrianbj-master' into dev

This commit is contained in:
Ryan Cramer
2016-10-04 16:42:56 -04:00
4 changed files with 50 additions and 30 deletions

View File

@@ -703,6 +703,7 @@ class SelectableOptionManager extends Wire {
$table = self::optionsTable;
$languages = $this->wire('languages');
$maxLen = $database->getMaxIndexLength();
if(strtolower($this->wire('config')->dbCharset) == 'utf8mb4') $maxLen -= 20;
// check for added languages
foreach($languages as $language) {
@@ -763,6 +764,7 @@ class SelectableOptionManager extends Wire {
if($query->rowCount() == 0) {
$engine = $this->wire('config')->dbEngine;
$charset = $this->wire('config')->dbCharset;
if(strtolower($charset) == 'utf8mb4') $maxLen -= 20;
$sql =
"CREATE TABLE " . self::optionsTable . " (" .
"fields_id INT UNSIGNED NOT NULL, " .
@@ -783,6 +785,10 @@ class SelectableOptionManager extends Wire {
}
public function uninstall() {
$this->wire('database')->exec("DROP TABLE " . self::optionsTable);
try {
$this->wire('database')->exec("DROP TABLE " . self::optionsTable);
} catch(\Exception $e) {
$this->warning($e->getMessage());
}
}
}

View File

@@ -826,6 +826,7 @@ class ProcessTemplate extends Process {
$select->attr('name', 'fieldgroup_fields');
$select->attr('id', 'fieldgroup_fields');
$select->attr('title', $this->_('Add Field'));
$select->attr('data-closeAddLabel', $this->_('Close and Add'));
$select->setAsmSelectOption('sortable', true);
$select->setAsmSelectOption('editLink', $this->wire('config')->urls->admin . "setup/field/edit?id={value}&fieldgroup_id={$template->fieldgroup->id}&modal=1&process_template=1");
$select->setAsmSelectOption('hideDeleted', false);

View File

@@ -2,11 +2,12 @@
function TemplateFieldAddDialog() {
var $a = $(this);
var closeOnSave = false;
var fieldReady = false;
var $iframe = pwModalWindow($a.attr('href'), {}, 'large');
$iframe.load(function() {
var $button;
var buttons = [];
var $icontents = $iframe.contents();
var n = 0;
@@ -16,48 +17,60 @@ function TemplateFieldAddDialog() {
// copy buttons in iframe to dialog
$icontents.find("#content form button.ui-button[type=submit]").each(function() {
var $button = $(this);
var text = $button.text();
var text = $(this).text();
var skip = false;
$button = $(this);
// avoid duplicate buttons
for(i = 0; i < buttons.length; i++) {
for(var i = 0; i < buttons.length; i++) {
if(buttons[i].text == text || text.length < 1) skip = true;
}
if(!skip) {
buttons[n] = {
'text': text,
'class': ($button.is('.ui-priority-secondary') ? 'ui-priority-secondary' : ''),
'class': ($button.hasClass('ui-priority-secondary') ? 'ui-priority-secondary' : ''),
'click': function() {
$button.click();
if(closeOnSave) setTimeout(function() {
var newFieldId = $icontents.find("#Inputfield_id:last").val();
$iframe.dialog('close');
var numOptions = $('#fieldgroup_fields option').size();
$("#fieldgroup_fields option").eq(1).before($("<option></option>").val(newFieldId).text($icontents.find("#Inputfield_name").val()));
$('#fieldgroup_fields option[value="'+newFieldId+'"]')
.attr('id', 'asm0option'+numOptions)
.attr('data-desc', ($icontents.find("#field_label").val()))
.attr('data-status', ($icontents.find("#Inputfield_type option:selected").text()));
$("#asmSelect0 option").eq(1).before($("<option></option>").val(newFieldId).text($icontents.find("#Inputfield_name").val()));
$("#asmSelect0").find('option:selected').removeAttr("selected");
$('#asmSelect0 option[value="'+newFieldId+'"]')
.attr('rel', 'asm0option'+numOptions)
.attr('selected', 'selected')
.addClass('asmOptionDisabled')
.attr('disabled', 'disabled')
.trigger('change')
.removeAttr("selected");
}, 500);
closeOnSave = true;
fieldReady = true;
}
};
n++;
};
}
$button.hide();
});
// if field has been saved once, now offer a Close & Add button
if(fieldReady) {
buttons[n] = {
'text': $('#fieldgroup_fields').attr('data-closeAddLabel'),
'class': ($button && $button.hasClass('ui-priority-secondary') ? 'ui-priority-secondary' : ''),
'click': function() {
setTimeout(function() {
var newFieldId = $icontents.find("#Inputfield_id:last").val();
$iframe.dialog('close');
var $options = $('#fieldgroup_fields option');
var numOptions = $options.length;
$options.eq(1).before($("<option></option>").val(newFieldId).text($icontents.find("#Inputfield_name").val()));
$('#fieldgroup_fields option[value="'+newFieldId+'"]')
.attr('id', 'asm0option'+numOptions)
.attr('data-desc', ($icontents.find("#field_label").val()))
.attr('data-status', ($icontents.find("#Inputfield_type option:selected").text()));
$("#asmSelect0 option").eq(1).before($("<option></option>")
.val(newFieldId).text($icontents.find("#Inputfield_name").val()));
$("#asmSelect0").find('option:selected').removeAttr("selected");
$('#asmSelect0 option[value="'+newFieldId+'"]')
.attr('rel', 'asm0option'+numOptions)
.attr('selected', 'selected')
.addClass('asmOptionDisabled')
.attr('disabled', 'disabled')
.trigger('change')
.removeAttr("selected");
}, 500);
}
};
}
$iframe.setButtons(buttons);
});

View File

@@ -1 +1 @@
function TemplateFieldAddDialog(){var b=$(this);var a=false;var c=pwModalWindow(b.attr("href"),{},"large");c.load(function(){var d=[];var e=c.contents();var f=0;e.find("#breadcrumbs ul.nav, #Inputfield_submit_save_field_copy").hide();e.find("#content form button.ui-button[type=submit]").each(function(){var h=$(this);var j=h.text();var g=false;for(i=0;i<d.length;i++){if(d[i].text==j||j.length<1){g=true}}if(!g){d[f]={text:j,"class":(h.is(".ui-priority-secondary")?"ui-priority-secondary":""),click:function(){h.click();if(a){setTimeout(function(){var l=e.find("#Inputfield_id:last").val();c.dialog("close");var k=$("#fieldgroup_fields option").size();$("#fieldgroup_fields option").eq(1).before($("<option></option>").val(l).text(e.find("#Inputfield_name").val()));$('#fieldgroup_fields option[value="'+l+'"]').attr("id","asm0option"+k).attr("data-desc",(e.find("#field_label").val())).attr("data-status",(e.find("#Inputfield_type option:selected").text()));$("#asmSelect0 option").eq(1).before($("<option></option>").val(l).text(e.find("#Inputfield_name").val()));$("#asmSelect0").find("option:selected").removeAttr("selected");$('#asmSelect0 option[value="'+l+'"]').attr("rel","asm0option"+k).attr("selected","selected").addClass("asmOptionDisabled").attr("disabled","disabled").trigger("change").removeAttr("selected")},500)}a=true}};f++}h.hide()});c.setButtons(d)});return false}$(document).ready(function(){$("#wrap_fieldgroup_fields p.description a").click(TemplateFieldAddDialog)});
function TemplateFieldAddDialog(){var b=$(this);var a=false;var c=pwModalWindow(b.attr("href"),{},"large");c.load(function(){var e;var d=[];var f=c.contents();var g=0;f.find("#breadcrumbs ul.nav, #Inputfield_submit_save_field_copy").hide();f.find("#content form button.ui-button[type=submit]").each(function(){var k=$(this).text();var j=false;e=$(this);for(var h=0;h<d.length;h++){if(d[h].text==k||k.length<1){j=true}}if(!j){d[g]={text:k,"class":(e.hasClass("ui-priority-secondary")?"ui-priority-secondary":""),click:function(){e.click();a=true}};g++}e.hide()});if(a){d[g]={text:$("#fieldgroup_fields").attr("data-closeAddLabel"),"class":(e&&e.hasClass("ui-priority-secondary")?"ui-priority-secondary":""),click:function(){setTimeout(function(){var j=f.find("#Inputfield_id:last").val();c.dialog("close");var h=$("#fieldgroup_fields option");var i=h.length;h.eq(1).before($("<option></option>").val(j).text(f.find("#Inputfield_name").val()));$('#fieldgroup_fields option[value="'+j+'"]').attr("id","asm0option"+i).attr("data-desc",(f.find("#field_label").val())).attr("data-status",(f.find("#Inputfield_type option:selected").text()));$("#asmSelect0 option").eq(1).before($("<option></option>").val(j).text(f.find("#Inputfield_name").val()));$("#asmSelect0").find("option:selected").removeAttr("selected");$('#asmSelect0 option[value="'+j+'"]').attr("rel","asm0option"+i).attr("selected","selected").addClass("asmOptionDisabled").attr("disabled","disabled").trigger("change").removeAttr("selected")},500)}}}c.setButtons(d)});return false}$(document).ready(function(){$("#wrap_fieldgroup_fields p.description a").click(TemplateFieldAddDialog)});