Implement feedback fixes

Enhancement Fix ModelAdmin import form not POSTing to correct form
This commit is contained in:
Will Rossiter 2016-12-21 16:23:00 +13:00 committed by Christopher Joe
parent cf5c055ded
commit 56c2363909
10 changed files with 62 additions and 49 deletions

View File

@ -666,7 +666,7 @@ i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Obj
function t(e){r(this,t)
var n=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))
return n.handleClick=n.handleClick.bind(n),n}return o(t,e),s(t,[{key:"render",value:function n(){return u["default"].createElement("button",{className:"grid-field__icon-action font-icon-"+this.props.icon+" btn--icon-large",
onClick:this.handleClick})}},{key:"handleClick",value:function i(e){return console.log("handle click"),!1}}]),t}(d["default"])
onClick:this.handleClick})}},{key:"handleClick",value:function i(e){this.props.handleClick(e,this.props.record.ID)}}]),t}(d["default"])
p.PropTypes={handleClick:u["default"].PropTypes.func.isRequired},t["default"]=p},function(e,t,n){"use strict"
function i(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){var n=["id"]
return n.reduce(function(e,n){return e.replace(":"+n,t[n])},e)}function a(e,t,n){var i={recordType:e},a={Accept:"text/json"},o=t.toLowerCase()
@ -2156,8 +2156,7 @@ var s=n(108),l=i(s),u=n(33),c=i(u),d=(0,l["default"])({})},function(e,t,n){"use
function i(e){return e&&e.__esModule?e:{"default":e}}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(){var e=arguments.length<=0||void 0===arguments[0]?d:arguments[0],t=arguments[1],n=null,i=null,a=null,s={}
switch(t.type){case"APOLLO_QUERY_RESULT":return e
case c["default"].CREATE_RECORD:return(0,l["default"])(o({},e,{}))
switch(t.type){case c["default"].CREATE_RECORD:return(0,l["default"])(o({},e,{}))
case c["default"].UPDATE_RECORD:return(0,l["default"])(o({},e,{}))
case c["default"].DELETE_RECORD:return(0,l["default"])(o({},e,{}))
case c["default"].FETCH_RECORDS_REQUEST:return e

View File

@ -855,6 +855,10 @@ body .ui-tooltip{ border-width:2px; }
top:6px;
cursor:pointer;
}
.chosen-container-multi .chosen-choices{
padding:4px 5px;
}
/*!
* Bootstrap v4.0.0-alpha.2 (http://getbootstrap.com)
* Copyright 2011-2015 Twitter, Inc.

View File

@ -18,9 +18,6 @@ class GridFieldAction extends SilverStripeComponent {
}
handleClick(event) {
console.log('handle click');
return false;
this.props.handleClick(event, this.props.record.ID);
}
}

View File

@ -147,17 +147,15 @@ $.entwine('ss', function($) {
backdrop.addClass('fade in').fadeIn();
}
$(this.data('target')).addClass('in');
var modal = $(this.data('target'));
// workaround until GridField rewritten into react.
var self = this;
$(this.data('target')).find('[data-dismiss]').on('click', function() {
modal.addClass('in');
modal.find('[data-dismiss]').on('click', function() {
backdrop.fadeOut(function() {
$(this).removeClass('in');
backdrop.removeClass('in');
});
$(self.data('target')).removeClass('in');
modal.removeClass('in');
})
}
});

View File

@ -10,10 +10,6 @@ function recordsReducer(state = initialState, action) {
let apolloRecordRelation = {};
switch (action.type) {
case 'APOLLO_QUERY_RESULT':
return state;
case ACTION_TYPES.CREATE_RECORD:
return deepFreeze(Object.assign({}, state, {}));

View File

@ -1 +1,5 @@
@import "../../../../node_modules/chosen-js/chosen.css";
.chosen-container-multi .chosen-choices {
padding: 4px 5px;
}

View File

@ -521,28 +521,33 @@ abstract class ModelAdmin extends LeftAndMain
$results = $loader->load($_FILES['_CsvFile']['tmp_name']);
$message = '';
if ($results->CreatedCount()) {
$message .= _t(
'ModelAdmin.IMPORTEDRECORDS',
"Imported {count} records.",
array('count' => $results->CreatedCount())
);
}
if ($results->UpdatedCount()) {
$message .= _t(
'ModelAdmin.UPDATEDRECORDS',
"Updated {count} records.",
array('count' => $results->UpdatedCount())
);
}
if ($results->DeletedCount()) {
$message .= _t(
'ModelAdmin.DELETEDRECORDS',
"Deleted {count} records.",
array('count' => $results->DeletedCount())
);
}
if (!$results->CreatedCount() && !$results->UpdatedCount()) {
if($results) {
if ($results->CreatedCount()) {
$message .= _t(
'ModelAdmin.IMPORTEDRECORDS',
"Imported {count} records.",
array('count' => $results->CreatedCount())
);
}
if ($results && $results->UpdatedCount()) {
$message .= _t(
'ModelAdmin.UPDATEDRECORDS',
"Updated {count} records.",
array('count' => $results->UpdatedCount())
);
}
if ($results->DeletedCount()) {
$message .= _t(
'ModelAdmin.DELETEDRECORDS',
"Deleted {count} records.",
array('count' => $results->DeletedCount())
);
}
if (!$results->CreatedCount() && !$results->UpdatedCount()) {
$message .= _t('ModelAdmin.NOIMPORT', "Nothing to import");
}
} else {
$message .= _t('ModelAdmin.NOIMPORT', "Nothing to import");
}

View File

@ -16,7 +16,7 @@
</div>
<div class="cms-content-header-tabs cms-tabset-nav-primary ss-ui-tabs-nav">
<% if $SearchForm || $ImportForm %>
<% if $SearchForm %>
<button id="filters-button" class="btn btn-secondary btn--icon-large font-icon-search no-text" title="<%t CMSPagesController_Tools_ss.FILTER 'Filter' %>"></button>
<% end_if %>
<ul class="cms-tabset-nav-primary">
@ -35,6 +35,20 @@
<div class="cms-content-view">
$EditForm
</div>
<% if ImportForm %>
<div id="{$EditForm.HTMLID}_ImportModal" class="modal fade grid-field-import" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content"><div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
$ImportForm
</div>
</div>
</div>
<% end_if %>
</div>
</div>

View File

@ -1,4 +1,4 @@
<% if $SearchForm || $ImportForm %>
<% if $SearchForm %>
<div id="cms-content-tools-ModelAdmin" class="cms-content-filters">
<% if $SearchForm %>
<h3 class="cms-panel-header"><%t ModelAdmin_Tools_ss.FILTER 'Filter' %></h3>

View File

@ -46,21 +46,17 @@ class GridFieldImportButton implements GridField_HTMLProvider
null
);
$button->addExtraClass('btn btn-secondary no-ajax font-icon-upload btn--icon-large action_import');
// means that you can only have 1 import per page
$button
->setAttribute('data-toggle', "modal")
->setAttribute('data-target', "#". $gridField->ID() . ' .grid-field-import');
->setAttribute('data-target', "#". $gridField->getForm()->getHTMLID() . '_ImportModal');
$button->setForm($gridField->getForm());
$extra = null;
if($this->importFormField) {
$extra = ($this->importFormField instanceof Form)
? $this->importFormField->forTemplate()
: $this->importFormField->Field();
}
return array(
$this->targetFragment => ($extra) ? '<p class="grid-csv-button">' . $button->Field() . '</p>'.$extra : '',
$this->targetFragment => '<p class="grid-csv-button">'. $button->Field() . '</p>'
);
}