Skip to content

Commit 334bf8d

Browse files
committed
Initial outlay of ImportExportController
1 parent 095721b commit 334bf8d

File tree

9 files changed

+244
-0
lines changed

9 files changed

+244
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php namespace Backend\Behaviors;
2+
3+
use Backend\Classes\ControllerBehavior;
4+
use League\Csv\Writer;
5+
6+
/**
7+
* Import/Export Controller Behavior
8+
* Adds features for importing and exporting data.
9+
*
10+
* @package october\backend
11+
* @author Alexey Bobkov, Samuel Georges
12+
*/
13+
class ImportExportController extends ControllerBehavior
14+
{
15+
16+
/**
17+
* Behavior constructor
18+
* @param Backend\Classes\Controller $controller
19+
*/
20+
public function __construct($controller)
21+
{
22+
parent::__construct($controller);
23+
24+
$this->addJs('js/october.importexport.js', 'core');
25+
$this->addCss('css/importexport.css', 'core');
26+
}
27+
28+
public function import()
29+
{
30+
31+
}
32+
33+
public function importRender()
34+
{
35+
return $this->importExportMakePartial('container');
36+
}
37+
38+
public function importRenderUpload()
39+
{
40+
return $this->importExportMakePartial('import_upload');
41+
}
42+
43+
public function importRenderFields()
44+
{
45+
return $this->importExportMakePartial('import_fields');
46+
}
47+
48+
/**
49+
* Controller accessor for making partials within this behavior.
50+
* @param string $partial
51+
* @param array $params
52+
* @return string Partial contents
53+
*/
54+
public function importExportMakePartial($partial, $params = [])
55+
{
56+
$contents = $this->controller->makePartial('import_export_'.$partial, $params + $this->vars, false);
57+
if (!$contents) {
58+
$contents = $this->makePartial($partial, $params);
59+
}
60+
61+
return $contents;
62+
}
63+
64+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
.import-behavior ul {
2+
margin: 0;
3+
padding: 0;
4+
list-style: none;
5+
}
6+
.import-behavior ul li.placeholder {
7+
display: block;
8+
position: relative;
9+
}
10+
.import-behavior ul li.dragged {
11+
position: absolute;
12+
z-index: 2000;
13+
-webkit-box-shadow: 0 3px 6px rgba(0, 0, 0, 0.075);
14+
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.075);
15+
}
16+
.import-behavior ul.import-file-columns li,
17+
.import-behavior ul.import-record-columns li {
18+
background: #f0f0f0;
19+
border: 1px solid #cccccc;
20+
border-radius: 3px;
21+
margin-bottom: 5px;
22+
}
23+
.import-behavior ul.import-file-columns li div.import-column-name > span,
24+
.import-behavior ul.import-record-columns li div.import-column-name > span,
25+
.import-behavior ul.import-file-columns li > span,
26+
.import-behavior ul.import-record-columns li > span {
27+
display: block;
28+
padding: 5px;
29+
}
30+
.import-behavior ul.import-file-columns li:before,
31+
.import-behavior ul.import-file-columns li:after {
32+
content: " ";
33+
display: table;
34+
}
35+
.import-behavior ul.import-file-columns li:after {
36+
clear: both;
37+
}
38+
.import-behavior ul.import-file-columns div.import-column-name {
39+
float: left;
40+
width: 50%;
41+
}
42+
.import-behavior ul.import-file-columns ul.import-column-bindings {
43+
float: right;
44+
width: 50%;
45+
}
46+
.import-behavior ul.import-column-bindings {
47+
background: #999;
48+
padding: 5px 5px;
49+
}
50+
.import-behavior ul.import-column-bindings li {
51+
background: transparent;
52+
border-color: transparent;
53+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Scripts for the Import/Export controller behavior.
3+
*/
4+
+function ($) { "use strict";
5+
6+
var ImportExportBehavior = function() {
7+
8+
}
9+
10+
$.oc.importExportBehavior = new ImportExportBehavior;
11+
}(window.jQuery);
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
@import "../../../../assets/less/core/boot.less";
2+
3+
@color-import-column-bg: #f0f0f0;
4+
@color-import-column-border: #ccc;
5+
6+
.import-behavior {
7+
8+
ul {
9+
margin: 0;
10+
padding: 0;
11+
list-style: none;
12+
13+
li.placeholder {
14+
display: block;
15+
position: relative;
16+
}
17+
18+
li.dragged {
19+
position: absolute;
20+
//opacity: 0.5;
21+
z-index: 2000;
22+
.box-shadow(0 3px 6px rgba(0,0,0,.075));
23+
}
24+
}
25+
26+
ul.import-file-columns,
27+
ul.import-record-columns {
28+
li {
29+
background: @color-import-column-bg;
30+
border: 1px solid @color-import-column-border;
31+
border-radius: 3px;
32+
margin-bottom: 5px;
33+
34+
div.import-column-name > span,
35+
> span {
36+
display: block;
37+
padding: 5px;
38+
}
39+
}
40+
}
41+
42+
ul.import-file-columns {
43+
li {
44+
.clearfix;
45+
}
46+
47+
div.import-column-name {
48+
float: left;
49+
width: 50%;
50+
}
51+
52+
ul.import-column-bindings {
53+
float: right;
54+
width: 50%;
55+
}
56+
}
57+
58+
ul.import-column-bindings {
59+
background: #999;
60+
padding: 5px 5px;
61+
li {
62+
background: transparent;
63+
border-color: transparent;
64+
}
65+
}
66+
67+
}

modules/backend/behaviors/importexportcontroller/partials/_button_export.htm

Whitespace-only changes.

modules/backend/behaviors/importexportcontroller/partials/_button_import.htm

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<div class="import-behavior">
2+
<h3>1. Upload a CSV file</h3>
3+
4+
<?= $this->importRenderUpload() ?>
5+
6+
<h3>2. Match fields to the CSV columns</h3>
7+
8+
<?= $this->importRenderFields() ?>
9+
</div>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
3+
<div class="row">
4+
<div class="col-md-6">
5+
File Columns
6+
7+
<ul class="import-file-columns">
8+
<li>
9+
<div class="import-column-name">
10+
<span>Name</span>
11+
</div>
12+
<ul class="import-column-bindings">
13+
</ul>
14+
</li>
15+
<li>
16+
<div class="import-column-name">
17+
<span>URL Name</span>
18+
</div>
19+
<ul class="import-column-bindings">
20+
</ul>
21+
</li>
22+
</ul>
23+
</div>
24+
<div class="col-md-6">
25+
Record Columns
26+
27+
<ul class="import-record-columns">
28+
<li><span>SKU</span></li>
29+
<li><span>Title</span></li>
30+
<li><span>Description</span></li>
31+
</ul>
32+
</div>
33+
</div>
34+
35+
<script>
36+
$('ul.import-record-columns, ul.import-column-bindings').sortable({
37+
group: 'import-fields',
38+
usePlaceholderClone: true
39+
})
40+
</script>

modules/backend/behaviors/importexportcontroller/partials/_import_upload.htm

Whitespace-only changes.

0 commit comments

Comments
 (0)