Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
fix(Editor): fixing bugs and making changes to the editor to make it …
Browse files Browse the repository at this point in the history
…more usable

Merge pull request #448 from qri-io/editor
  • Loading branch information
ramfox authored Jan 29, 2019
2 parents 17aa8e8 + c064505 commit b4c474f
Show file tree
Hide file tree
Showing 16 changed files with 812 additions and 108 deletions.
47 changes: 45 additions & 2 deletions lib/actions/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import {
EDITOR_UPDATE_BODY,
EDITOR_SET_VIZ_SCRIPT,
EDITOR_SET_TRANSFORM_SCRIPT,
EDITOR_REMOVE_SECTION
EDITOR_REMOVE_SECTION,
EDITOR_SET_SCHEMA,
EDITOR_SET_BODY_VIEW,
EDITOR_SET_COL_ORDER,
EDITOR_SET_ROW_ORDER,
EDITOR_SET_BODY_ERROR
} from '../constants/editor'

import {
Expand All @@ -26,7 +31,7 @@ const blankDataset = {}

// initDataset resets the editor to a blank dataset
// TODO - consider renaming this to like "initEditor" or something to avoid confusion with "newDataset", "saveDataset" actions
export function initDataset (name = '', dataset = blankDataset, transformScript = '', vizScript = '', body = '') {
export function initDataset (name = '', dataset = blankDataset, transformScript = '', vizScript = '', body = undefined) {
return {
type: EDITOR_INIT_DATASET,
name,
Expand Down Expand Up @@ -132,6 +137,16 @@ export function setStructure (structure = {}) {
}
}

// setSchema updates/replaces the schema in
// the dataset.structure section
// as well as the the schema string section
export function setSchema (schema = '') {
return {
type: EDITOR_SET_SCHEMA,
schema
}
}

// setViz replaces/updates the editor viz object
export function setViz (viz = {}) {
return {
Expand Down Expand Up @@ -188,3 +203,31 @@ export function removeSection (section = '') {
section
}
}

export function setBodyView (view = '') {
return {
type: EDITOR_SET_BODY_VIEW,
view
}
}

export function setColOrder (order) {
return {
type: EDITOR_SET_COL_ORDER,
order
}
}

export function setRowOrder (order) {
return {
type: EDITOR_SET_ROW_ORDER,
order
}
}

export function setBodyError (error) {
return {
type: EDITOR_SET_BODY_ERROR,
error
}
}
6 changes: 3 additions & 3 deletions lib/components/dataset/Body.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Spinner from '../chrome/Spinner'
import DatasetRefProps from '../../propTypes/datasetRefProps'
import Button from '../chrome/Button'
import HandsonTable from '../HandsonTable'
import { extractSchema } from '../../selectors/dataset'
import { extractColumnHeaders } from '../../selectors/dataset'
import BodyReadOnly from './BodyReadOnly'

export default class Body extends Base {
Expand All @@ -20,7 +20,7 @@ export default class Body extends Base {

makeColHeaders () {
const { datasetRef } = this.props
const schema = extractSchema(datasetRef)
const schema = extractColumnHeaders(datasetRef)
return schema && schema.map(i => i.title)
}

Expand Down Expand Up @@ -49,7 +49,7 @@ export default class Body extends Base {

// button for switching views

if (body && datasetRef.dataset && datasetRef.dataset.structure && datasetRef.dataset.structure.format === 'csv') {
if (body && datasetRef.dataset && datasetRef.dataset.structure && datasetRef.dataset.structure.depth === 2) {
return <HandsonTable body={body} readOnly={readOnly} colHeaders={this.makeColHeaders()} layout={layout} />
}

Expand Down
Loading

0 comments on commit b4c474f

Please sign in to comment.