Skip to content

Commit

Permalink
Merge pull request #28 from First-Peoples-Cultural-Council/develop
Browse files Browse the repository at this point in the history
Merging changes into master for release
  • Loading branch information
dy2288 authored Jan 25, 2018
2 parents 95fc135 + 072731b commit 3f16bd4
Show file tree
Hide file tree
Showing 11 changed files with 381 additions and 48 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/common/ProviderHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export default {
},
regex: {
ANYTHING_BUT_SLASH : "([^/]*)",
ANY_LANGUAGE_CODE : "(en|fr)",
WORKSPACE_OR_SECTION : "(sections|Workspaces)",
KIDS_OR_DEFAULT : "(kids|explore)"
}
Expand Down
38 changes: 27 additions & 11 deletions app/assets/javascripts/views/AppFrontController.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ import { PageDialectViewAlphabet } from 'views/pages';

import { PageJigsawGame, PageColouringBook, PageWordSearch, PagePictureThis, PageConcentration, PageWordscramble, PageQuiz, PageHangman} from 'views/pages';

import { PageGetStarted, PageContribute, PagePlay, PageSearch, PageTasks, PageUsersProfile, PageUsersRegister, PageUsersForgotPassword, PageDialectLearnWordsCategories, PageDialectLearnPhrasesCategories } from 'views/pages';
import { PageGetStarted, PageContribute, PagePlay, PageSearch, PageTasks, PageUsersProfile, PageUsersRegister, PageUserLogin, PageUsersForgotPassword, PageDialectLearnWordsCategories, PageDialectLearnPhrasesCategories } from 'views/pages';

import { PageExploreDialectEdit, PageDialectWordEdit, PageDialectAlphabetCharacterEdit, PageDialectEditMedia, PageDialectGalleryEdit, PageDialectPhraseEdit, PageDialectBookEdit, PageDialectBookEntryEdit } from 'views/pages/edit';
import {
PageDialectWordsCreate, PageDialectPhrasesCreate, PageDialectStoriesAndSongsCreate,
PageDialectGalleryCreate, PageDialectCategoryCreate, PageDialectPhraseBooksCreate,
PageDialectContributorsCreate, PageDialectStoriesAndSongsBookEntryCreate } from 'views/pages/create';

import { ServiceShortURL } from 'views/services';

/**
* Parameter matching class
*/
Expand All @@ -52,6 +54,7 @@ class paramMatch {
// Regex helper
const ANYTHING_BUT_SLASH = new RegExp(ProviderHelpers.regex.ANYTHING_BUT_SLASH);
const WORKSPACE_OR_SECTION = new RegExp(ProviderHelpers.regex.WORKSPACE_OR_SECTION);
const ANY_LANGUAGE_CODE = new RegExp(ProviderHelpers.regex.ANY_LANGUAGE_CODE);
const KIDS_OR_DEFAULT = new paramMatch('theme', RegExp(ProviderHelpers.regex.KIDS_OR_DEFAULT));

const REMOVE_FROM_BREADCRUMBS = ['FV', 'sections', 'Data', 'Workspaces', 'edit', 'search'];
Expand Down Expand Up @@ -137,6 +140,7 @@ export default class AppFrontController extends Component {
},
{
path: ['home'],
alias: [ANY_LANGUAGE_CODE, 'home'],
page: <PageHome />,
title: 'Home',
breadcrumbs: false,
Expand Down Expand Up @@ -164,16 +168,6 @@ export default class AppFrontController extends Component {
title: 'Kids Home',
page: <PageKidsHome />
},
{
path: ['get-started'],
title: 'Getting Started',
page: <PageGetStarted />
},
{
path: ['contribute'],
title: 'Contribute',
page: <PageContribute />
},
{
path: ['play'],
title: 'Games',
Expand All @@ -189,6 +183,11 @@ export default class AppFrontController extends Component {
title: 'Register',
page: <PageUsersRegister />
},
{
path: ['login'],
title: 'User Login',
page: <PageUserLogin />
},
{
path: ['profile'],
title: 'User Profile',
Expand All @@ -209,6 +208,12 @@ export default class AppFrontController extends Component {
target: function(params) { return '/explore/FV/sections/Data/'; }
}]
},
{
path: [new paramMatch('area', WORKSPACE_OR_SECTION), new paramMatch('dialectFriendlyName', ANYTHING_BUT_SLASH)],
title: 'Dialect Short Url',
page: <ServiceShortURL />,
redirects: [WORKSPACE_TO_SECTION_REDIRECT]
},
{
path: [KIDS_OR_DEFAULT, 'FV', new paramMatch('area', WORKSPACE_OR_SECTION), 'Data'],
title: '{$theme} Dialects',
Expand Down Expand Up @@ -658,6 +663,12 @@ export default class AppFrontController extends Component {
routes.forEach(function(value, key) {

let matchTest = this._matchPath(value.get('path'), pathArray);
let matchAlias = this._matchPath(value.get('alias'), pathArray);

// If only the alias matched, redirect to the original path
if (matchAlias.matched && !matchTest.matched) {
window.location.replace('/' + value.get('path').join());
}

if (matchTest.matched) {

Expand Down Expand Up @@ -881,6 +892,10 @@ export default class AppFrontController extends Component {
// Remove empties from path array, return Immutable list
const currentPathArray = Immutable.fromJS(urlPath.filter(function(e){ return e; }));

if (!pathMatchArray) {
return false;
}

if (pathMatchArray.size != currentPathArray.size) {
return { matched: false, routeParams: {} };
}
Expand Down Expand Up @@ -929,6 +944,7 @@ export default class AppFrontController extends Component {
if (!matchedPage) {
page = <div>404</div>;
} else {

let clonedElement = React.cloneElement(matchedPage.get('page').toJS(), { routeParams: matchedRouteParams });

// For print view return page only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export default class AddMediaComponent extends Component {
<div style={{display: 'inline'}}>
<RaisedButton label={this.props.label} onTouchTap={this.handleOpen} />
<Dialog
title={"Create New " + fileTypeLabel + " in the " + selectn('response.properties.dc:title', this.props.dialect) + " dialect."}
title={"Create New " + fileTypeLabel + " in the " + selectn('properties.dc:title', this.props.dialect) + " dialect."}
actions={actions}
modal={true}
autoScrollBodyContent={true}
Expand Down
56 changes: 28 additions & 28 deletions app/assets/javascripts/views/components/Navigation/Login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import ActionExitToAppIcon from 'material-ui/lib/svg-icons/action/exit-to-app';

import CircularProgress from 'material-ui/lib/circular-progress';

import {BrowserView, MobileView, isBrowser, isMobile} from 'react-device-detect';

@provide
export default class Login extends Component {

Expand Down Expand Up @@ -68,6 +70,11 @@ export default class Login extends Component {

event.preventDefault();

if(isMobile) {
this._onNavigateRequest("login");
return;
}

this.setState({
open: true
});
Expand All @@ -84,9 +91,14 @@ export default class Login extends Component {
let username = this.refs.username.getValue();
let password = this.refs.password.getValue();

if ( username !== null && password !== null) {
this.setState({loginAttempted: true});
this.props.login(username, password);
if (username !== null && password !== null) {
if (username.length > 0 && password.length > 0) {

console.log('About to attempt login, desktop.');

this.setState({loginAttempted: true});
this.props.login(username, password);
}
}

this._handleClose();
Expand Down Expand Up @@ -130,7 +142,6 @@ export default class Login extends Component {
} else {
if (this.state.loginAttempted) {
loginFeedbackMessage = "Username or password incorrect.";

if (this.props.computeLogin.isError) {
loginFeedbackMessage = this.props.computeLogin.error;
}
Expand All @@ -139,39 +150,28 @@ export default class Login extends Component {

return (
<div style={{display: "inline-block", paddingTop: '15px', maxWidth: '205px'}}>
<FlatButton ref={(el)=>{this.anchorEl = el}} label={this.props.label} style={{color: themePalette.alternateTextColor}} onTouchTap={this._handleOpen} />

<FlatButton ref={(el)=>{this.anchorEl = el}} label={this.props.label} style={{"color": themePalette.alternateTextColor}} onTouchTap={this._handleOpen} />
<Popover open={this.state.open}
anchorEl={ReactDOM.findDOMNode(this.anchorEl)}
useLayerForClickAway={false}
style={{marginTop: '-14px', backgroundColor: 'transparent', boxShadow: 'none'}}
anchorOrigin={{horizontal: 'left', vertical: 'bottom'}}
targetOrigin={{horizontal: 'middle', vertical: 'top'}}
style={{marginTop:"-14px", "backgroundColor":"transparent", "boxShadow":"none"}}
anchorOrigin={{"horizontal":"left", "vertical":"bottom"}}
targetOrigin={{"horizontal":"middle", "vertical":"top"}}
onRequestClose={this._handleClose}>

<div style={{width: '205px'}}>

<img style={{position: 'relative', top: '14px', zIndex: 999999, left: '65%'}} src="/assets/images/popover-arrow.png" alt="" />

<div style={{backgroundColor: '#fff', padding:'10px', width: '100%'}}>
<h6>Sign In Below <a style={{cursor: 'pointer', fontWeight: 100}} onTouchTap={this._onNavigateRequest.bind(this, 'forgotpassword')} className="pull-right">Forgot?</a></h6>

<div><TextField style={Object.assign({}, TextFieldStyle, {margin: '15px 0'})} underlineShow={false} ref="username" hintText="Username" /></div>
<div style={{"width":"205px"}}>
<img style={{"position":"relative", "top":"14px", "zIndex":"999999", "left":"65%"}} src="/assets/images/popover-arrow.png" alt="" />
<div style={{"backgroundColor":"#fff", "padding":"10px", "width":"100%"}}>
<h6>Sign In Below <a style={{"cursor":"pointer", "fontWeight":"100"}} onTouchTap={this._onNavigateRequest.bind(this, "forgotpassword")} className="pull-right">Forgot?</a></h6>
<div><TextField style={Object.assign({}, TextFieldStyle, {"margin":"15px 0"})} underlineShow={false} ref="username" hintText="Username" /></div>
<div><TextField style={TextFieldStyle} underlineShow={false} ref="password" type="password" hintText="Password" /></div>

<p style={{margin: '10px 0', fontSize: '12px', backgroundColor: themePalette.primary4ColorLightest, padding: '0 3px'}}>{loginFeedbackMessage}</p>

<RaisedButton style={{width: '100%'}} secondary={true} onTouchTap={this._handleLogin} label="Sign in"/>

<h6 style={{fontWeight: 500, paddingTop: '10px'}}>New to FirstVoices?</h6>

<RaisedButton style={{width: '100%'}} primary={true} onTouchTap={this._onNavigateRequest.bind(this, 'register')} label="Register"/>
<p style={{"margin":"10px 0", "fontSize":"12px", "backgroundColor":themePalette.primary4ColorLightest, "padding":"0 3px"}}>{loginFeedbackMessage}</p>
<RaisedButton style={{"width":"100%"}} secondary={true} onTouchTap={this._handleLogin} label="Sign in"/>
<h6 style={{"fontWeight":"500", "paddingTop":"10px"}}>New to FirstVoices?</h6>
<RaisedButton style={{"width":"100%"}} primary={true} onTouchTap={this._onNavigateRequest.bind(this, "register")} label="Register"/>
</div>

</div>

</Popover>

</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default class PageDialectLearnAlphabet extends PageDialectLearnBase {
</PromiseWrapper>;
}

return <PromiseWrapper renderOnError={true} computeEntities={computeEntities}>
return <PromiseWrapper computeEntities={computeEntities}>

<Header
portal={{compute: computePortal, update: updatePortal}}
Expand Down
25 changes: 23 additions & 2 deletions app/assets/javascripts/views/pages/explore/dialect/media/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,32 @@ export default class PageDialectMediaEdit extends Component {
return false;
}

_navigateToMediaPage()
{
let mediaPath = '';

for(let value of this.props.splitWindowPath) {
mediaPath += '/'+ value;
if(value === 'media') {
break;
}
}
if(mediaPath.length > 0) {
this.props.pushWindowPath(mediaPath);
}
}

_onRequestSaveForm(e) {

// Prevent default behaviour
e.preventDefault();

let formValue = this.refs["form_resource"].getValue();
let resource = ProviderHelpers.getEntry(this.props.computeResource, this.state.resourcePath);

// Passed validation
if (formValue) {
let resource = ProviderHelpers.getEntry(this.props.computeResource, this.state.resourcePath);


// TODO: Find better way to construct object then accessing internal function
// Create new document rather than modifying the original document
let newDocument = new Document(resource.response, {
Expand All @@ -123,10 +138,16 @@ export default class PageDialectMediaEdit extends Component {
this.props.updateResource(newDocument);

this.setState({ formValue: formValue });

if(resource.action === "FV_RESOURCE_UPDATE_SUCCESS" || resource.action === "FV_RESOURCE_FETCH_SUCCESS") {
this._navigateToMediaPage();
}

} else {
//let firstError = this.refs["form_resource_create"].validate().firstError();
window.scrollTo(0, 0);
}

}

render() {
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/views/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import PagePlay from './play'
import PageSearch from './search'
import PageTasks from './tasks'
import PageUsersRegister from './users/register'
import PageUserLogin from './users/login'
import PageUsersForgotPassword from './users/forgotpassword'
import PageUsersProfile from './users/profile'

Expand Down Expand Up @@ -104,6 +105,7 @@ module.exports = {
PageSearch,
PageTasks,
PageUsersRegister,
PageUserLogin,
PageUsersForgotPassword,
PageUsersProfile,

Expand Down
Loading

0 comments on commit 3f16bd4

Please sign in to comment.