This commit is contained in:
Juan Ferrer Toribio 2016-10-06 11:23:54 +02:00
commit 5a5820328c
47 changed files with 418 additions and 82 deletions

View File

@ -1,3 +1,6 @@
import {bootstrap} from './bootstrap'; import {bootstrap} from './bootstrap';
import * as spliting from './spliting' import * as spliting from './spliting';
import * as routes from './routes';
bootstrap(); bootstrap();

View File

@ -0,0 +1,10 @@
{
"name": "@salix/core",
"version": "0.0.0",
"description": "",
"main": "index.js",
"repository": {
"type": "git",
"url": "http://git.verdnatura.es:/salix"
}
}

21
@salix/app/src/routes.js Normal file
View File

@ -0,0 +1,21 @@
import * as core from '@salix/core';
import * as spliting from './spliting';
core.module.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise("/");
$stateProvider
.state('index', {
url: "/index",
template :'<customer-add></customer-add>',
resolve: {
loader: function($ocLazyLoad, $q){
return $q((resolve) => {
spliting.crud($ocLazyLoad, resolve);
});
}
}
})
});

View File

@ -1,19 +1,20 @@
const crud = () => { export const crud = (lazy, resolve) => {
require.ensure([], () => { require.ensure([], () => {
require('@salix/crud') var module = require('@salix/crud');
resolve(lazy.load({name:'crud'}));
}, "salix.crud"); }, "salix.crud");
}; };
const compras = () => { export const compras = () => {
require.ensure([], () => { require.ensure([], () => {
require('@salix/compras') require('@salix/compras')
}, "salix.compras"); }, "salix.compras");
}; };
const ventas = () => { export const ventas = () => {
require.ensure([], () => { require.ensure([], () => {
require('@salix/ventas') require('@salix/ventas')
}, "salix.ventas"); }, "salix.ventas");
}; };
const pagos = () => { export const pagos = () => {
require.ensure([], () => { require.ensure([], () => {
require('@salix/pagos') require('@salix/pagos')
}, "salix.pagos"); }, "salix.pagos");

View File

@ -13,7 +13,7 @@ export function factory() {
return { return {
template: template, template: template,
default: { default: {
texto: DEFAULT_TEXT, text: DEFAULT_TEXT,
className: DEFAULT_CLASS, className: DEFAULT_CLASS,
enabled: 'true', enabled: 'true',
typeName: 'button' typeName: 'button'

View File

@ -1,3 +1,3 @@
<button type = "*[typeName]" class="*[className]" *[enabled] > <button type = "*[typeName]*" class="*[className]*" *[enabled]* >
{{texto}} *[text]*
</button> </button>

View File

@ -13,7 +13,7 @@ export function factory() {
return { return {
template: template, template: template,
default: { default: {
texto: DEFAULT_TEXT, text: DEFAULT_TEXT,
className: DEFAULT_CLASS, className: DEFAULT_CLASS,
enabled: 'true', enabled: 'true',
typeName: 'button' typeName: 'button'

View File

@ -0,0 +1,2 @@
<!-- por definir -->

View File

@ -0,0 +1 @@
// por definir

View File

@ -0,0 +1,18 @@
import {module as _module} from '../module';
import * as resolveFactory from '../resolveDefaultComponents';
import * as util from '../util';
const _NAME = 'check';
export const NAME = util.getName(_NAME);
directive.$inject =[resolveFactory.NAME];
export function directive (resolve){
return{
require:'E',
template: function(_,attr){
return resolve.getTemplate(_NAME, attr);
}
}
}
_module.directive(NAME,directive);

View File

@ -0,0 +1,3 @@
<input type="checkbox" class="*[className]*" *[enabled]* >
<span class="mdl-checkbox__label"> *[text]*</span>

View File

@ -0,0 +1,23 @@
import {module as _module} from '../module';
import * as util from '../util';
import * as constant from '../constants';
import template from './check.mt.html';
const _NAME = 'check';
const DEFAULT_TEXT = 'check';
const DEFAULT_CLASS = 'mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect';
export const NAME = util.getFactoryName(_NAME + constant.MATERIAL_DESIGN_FRAMEWORK);
export function factory() {
return {
template: template,
default: {
text: DEFAULT_TEXT,
enabled: 'true',
className: DEFAULT_CLASS
}
}
}
_module.factory(NAME, factory);

View File

@ -1,10 +1,22 @@
/** /**
* export public module * export public module
*/ */
export {NAME} from './module'; export * from './module';
export * from './util'; export * from './util';
export {NAME as RESOLVEDEFAULTCOMPONENT, ResolveDefaultComponent} from './resolveDefaultComponents' export {NAME as RESOLVEDEFAULTCOMPONENT, ResolveDefaultComponent} from './resolveDefaultComponents'
export {NAME as INTERPOLATE,Interpolate} from './interpolate' export {NAME as INTERPOLATE,Interpolate} from './interpolate'
export {NAME as BUTTON,directive as ButtonDirective} from './button/button' export {NAME as BUTTON,directive as ButtonDirective} from './button/button'
export {NAME as BUTTONMT,factory as buttonmt} from './button/button.mt' export {NAME as BUTTONMT,factory as buttonmt} from './button/button.mt'
export {NAME as BUTTONBT,factory as buttonbt} from './button/button.bt' export {NAME as BUTTONBT,factory as buttonbt} from './button/button.bt'
export {NAME as CHECK,directive as CheckDirective} from './check/check'
export {NAME as CHECKMT,factory as checknmt} from './check/check.mt'
export {NAME as CHECKBT,factory as checkbt} from './check/check.bt'
export {NAME as RADIO,directive as RadioDirective} from './radio/radio'
export {NAME as RADIOMT,factory as radionmt} from './radio/radio.mt'
export {NAME as RADIOBT,factory as radiobt} from './radio/radio.bt'
export {NAME as TEXTFIELD,directive as TextfieldDirective} from './textfield/textfield'
export {NAME as TEXTFIELDMT,factory as textfieldmt} from './textfield/textfield.mt'
export {NAME as TEXTFIELDBT,factory as textfieldbt} from './textfield/textfield.bt'
export {NAME as LABEL,directive as LabelDirective} from './label/label'
export {NAME as LABELMT,factory as labelmt} from './label/label.mt'
export {NAME as LABELBT,factory as labelbt} from './label/label.bt'

View File

@ -1,14 +1,52 @@
import {module as _module} from './module'; import {module as _module} from './module';
import * as util from './util'; import * as util from './util';
import {ng} from '@salix/vendor'
export const NAME = util.getProviderName('interpolate'); export const NAME = util.getProviderName('interpolate');
function minErr(){
}
function stringify(value) {
if (value == null) { // null || undefined
return '';
}
switch (typeof value) {
case 'string':
break;
case 'number':
value = '' + value;
break;
default:
value = angular.toJson(value);
}
return value;
}
var $interpolateMinErr =ng.angular.$interpolateMinErr = ng.$$minErr('$interpolate');
$interpolateMinErr.throwNoconcat = function (text) {
throw $interpolateMinErr('noconcat',
'Error while interpolating: {0}\nStrict Contextual Escaping disallows ' +
'interpolations that concatenate multiple expressions when a trusted value is ' +
'required. See http://docs.angularjs.org/api/ng.$sce', text);
};
$interpolateMinErr.interr = function (text, err) {
return $interpolateMinErr('interr', 'Can\'t interpolate: {0}\n{1}', text, err.toString());
};
export class Interpolate export class Interpolate
{ {
contructor (){ constructor (){
this._startSymbol='*['; this._startSymbol='*[';
this._endSymbol = ']'; this._endSymbol = ']*';
} }
set startSymbol (value) { set startSymbol (value) {
@ -28,19 +66,21 @@ export class Interpolate
return this._endSymbol; return this._endSymbol;
} }
}; };
$get($parse, $exceptionHandler, $sce) { $get($parse, $exceptionHandler, $sce) {
var startSymbolLength = this._startSymbol.length, var startSymbolLength = this._startSymbol.length,
endSymbolLength = this._endSymbol.length, endSymbolLength = this._endSymbol.length,
escapedStartRegexp = new RegExp(this._startSymbol.replace(/./g, escape), 'g'), escapedStartRegexp = new RegExp(this._startSymbol.replace(/./g, escape), 'g'),
escapedEndRegexp = new RegExp(this._endSymbol.replace(/./g, escape), 'g'); escapedEndRegexp = new RegExp(this._endSymbol.replace(/./g, escape), 'g'),
self = this;
function escape(ch) { function escape(ch) {
return '\\\\\\' + ch; return '\\\\\\' + ch;
} }
function unescapeText(text) { function unescapeText(text) {
return text.replace(escapedStartRegexp, this._startSymbol). return text.replace(escapedStartRegexp, self._startSymbol).
replace(escapedEndRegexp, this._endSymbol); replace(escapedEndRegexp, self._endSymbol);
} }
// TODO: this is the same as the constantWatchDelegate in parse.js // TODO: this is the same as the constantWatchDelegate in parse.js
@ -55,7 +95,7 @@ export class Interpolate
function $interpolate(text, mustHaveExpression, trustedContext, allOrNothing) function $interpolate(text, mustHaveExpression, trustedContext, allOrNothing)
{ {
// Provide a quick exit and simplified result function for text with no interpolation // Provide a quick exit and simplified result function for text with no interpolation
if (!text.length || text.indexOf(this._startSymbol) === -1) if (!text.length || text.indexOf(self._startSymbol) === -1)
{ {
var constantInterp; var constantInterp;
if (!mustHaveExpression) { if (!mustHaveExpression) {
@ -80,12 +120,12 @@ export class Interpolate
expressionPositions = []; expressionPositions = [];
while (index < textLength) { while (index < textLength) {
if (((startIndex = text.indexOf(this._startSymbol, index)) !== -1) && if (((startIndex = text.indexOf(self._startSymbol, index)) !== -1) &&
((endIndex = text.indexOf(this._endSymbol, startIndex + this._startSymbolLength)) !== -1)) { ((endIndex = text.indexOf(self._endSymbol, startIndex + startSymbolLength)) !== -1)) {
if (index !== startIndex) { if (index !== startIndex) {
concat.push(unescapeText(text.substring(index, startIndex))); concat.push(unescapeText(text.substring(index, startIndex)));
} }
exp = text.substring(startIndex + this._startSymbolLength, endIndex); exp = text.substring(startIndex + startSymbolLength, endIndex);
expressions.push(exp); expressions.push(exp);
parseFns.push($parse(exp, parseStringifyInterceptor)); parseFns.push($parse(exp, parseStringifyInterceptor));
index = endIndex + endSymbolLength; index = endIndex + endSymbolLength;
@ -164,4 +204,4 @@ export class Interpolate
} }
_module.provider(NAME, Interpolate); _module.provider(NAME, () => new Interpolate());

View File

@ -0,0 +1,2 @@
<!-- por definir -->

View File

@ -0,0 +1 @@
// por definir

View File

@ -0,0 +1,18 @@
import {module as _module} from '../module';
import * as resolveFactory from '../resolveDefaultComponents';
import * as util from '../util';
const _NAME = 'label';
export const NAME = util.getName(_NAME);
directive.$inject =[resolveFactory.NAME];
export function directive (resolve){
return{
require:'E',
template: function(_,attr){
return resolve.getTemplate(_NAME, attr);
}
}
}
_module.directive(NAME,directive);

View File

@ -0,0 +1 @@
<label>*[text]*</label>

View File

@ -0,0 +1,20 @@
import {module as _module} from '../module';
import * as util from '../util';
import * as constant from '../constants';
import template from './label.mt.html';
const _NAME = 'label';
const DEFAULT_TEXT = 'label';
export const NAME = util.getFactoryName(_NAME + constant.MATERIAL_DESIGN_FRAMEWORK);
export function factory() {
return {
template: template,
default: {
text: DEFAULT_TEXT
}
}
}
_module.factory(NAME, factory);

View File

@ -5,3 +5,4 @@ const DEPENDENCIES = getVendorDependencies(vendors)
export const NAME = getModuleName('core'); export const NAME = getModuleName('core');
export const module = vendors.ng.module(NAME,DEPENDENCIES); export const module = vendors.ng.module(NAME,DEPENDENCIES);

View File

@ -0,0 +1,2 @@
<!-- por definir -->

View File

@ -0,0 +1 @@
// por definir

View File

@ -0,0 +1,18 @@
import {module as _module} from '../module';
import * as resolveFactory from '../resolveDefaultComponents';
import * as util from '../util';
const _NAME = 'radio';
export const NAME = util.getName(_NAME);
directive.$inject =[resolveFactory.NAME];
export function directive (resolve){
return{
require:'E',
template: function(_,attr){
return resolve.getTemplate(_NAME, attr);
}
}
}
_module.directive(NAME,directive);

View File

@ -0,0 +1,2 @@
<input type="radio" class="*[className]*" *[enabled]* >
<span class="mdl-radio__label"> *[text]*</span>

View File

@ -0,0 +1,23 @@
import {module as _module} from '../module';
import * as util from '../util';
import * as constant from '../constants';
import template from './radio.mt.html';
const _NAME = 'radio';
const DEFAULT_TEXT = 'radio';
const DEFAULT_CLASS = 'mdl-radio mdl-js-radio mdl-js-ripple-effect';
export const NAME = util.getFactoryName(_NAME + constant.MATERIAL_DESIGN_FRAMEWORK);
export function factory() {
return {
template: template,
default: {
text: DEFAULT_TEXT,
enabled: 'true',
className: DEFAULT_CLASS
}
}
}
_module.factory(NAME, factory);

View File

@ -1,37 +1,39 @@
import {module as _module} from './module'; import {module as _module} from './module';
import * as util from './util'; import * as util from './util';
import constant from './constants'; import constant from './constants';
import interpolate from './interpolate'; import Interpolate from './interpolate';
export const NAME = util.getProviderName('ResolveDefaultComponent'); export const NAME = util.getProviderName('ResolveDefaultComponent');
export class ResolveDefaultComponent { export class ResolveDefaultComponent {
constructor(){ constructor(){
this._name="mt"; this._frameworkName="mt";
} }
set frameworkName(value){ set frameworkName(value){
//mt or bt //mt or bt
this._frameworkName = value; this._frameworkName = value;
} }
$get($injector,interpolate){ $get($injector,vnInterpolate){
//Service Locator //Service Locator
return { return {
getTemplate:function(name ,attr){ getTemplate:function(name ,attr){
this._frameworkName="mt";
let _name = util.getFactoryName( name + this._frameworkName); let _name = util.getFactoryName( name + this._frameworkName);
let defaultfactory = $injector.has(_name) ? $injector.get():undefined; // vnbutonmtFactory let defaultfactory = $injector.has(_name) ? $injector.get(_name):undefined; // vnbutonmtFactory
if(!defaultfactory) if(!defaultfactory)
{ {
throw new Error("factoty is not defined"); throw new Error("factory is not defined");
} }
let defaultValues = defaultfactory.default; let defaultValues = defaultfactory.default;
let template = defaultfactory.template; let template = defaultfactory.template;
let scope = Object.assign(defaultValues || {},attr||{}); let scope = Object.assign(defaultValues || {},attr||{});
return template && interpolate(template)(scope); return template && vnInterpolate(template)(scope);
} }
}; };
} }
} }
_module.provider(NAME,ResolveDefaultComponent) // _module.provider(NAME,ResolveDefaultComponent)
_module.provider(NAME,() => new ResolveDefaultComponent());

View File

@ -0,0 +1,2 @@
<!-- por definir -->

View File

@ -0,0 +1 @@
// por definir

View File

@ -0,0 +1,18 @@
import {module as _module} from '../module';
import * as resolveFactory from '../resolveDefaultComponents';
import * as util from '../util';
const _NAME = 'textfield';
export const NAME = util.getName(_NAME);
directive.$inject =[resolveFactory.NAME];
export function directive (resolve){
return{
require:'E',
template: function(_,attr){
return resolve.getTemplate(_NAME, attr);
}
}
}
_module.directive(NAME,directive);

View File

@ -0,0 +1,4 @@
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="*[className]*" type="*[type]*" *[enabled]*>
<label class="mdl-textfield__label">*[text]*</label>
</div>

View File

@ -0,0 +1,25 @@
import {module as _module} from '../module';
import * as util from '../util';
import * as constant from '../constants';
import template from './textfield.mt.html';
const _NAME = 'textfield';
const DEFAULT_TEXT = 'text';
const DEFAULT_CLASS = 'mdl-textfield__input';
const DEFAULT_TYPE = 'text';
export const NAME = util.getFactoryName(_NAME + constant.MATERIAL_DESIGN_FRAMEWORK);
export function factory() {
return {
template: template,
default: {
text: DEFAULT_TEXT,
enabled: 'enabled',
className: DEFAULT_CLASS,
type: DEFAULT_TYPE
}
}
}
_module.factory(NAME, factory);

1
@salix/crud/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules

View File

@ -1,3 +1 @@
import * as vendors from '@salix/vendor' export * from './src/crud';
import * as core from '@salix/core'
console.log('crud');

10
@salix/crud/package.json Normal file
View File

@ -0,0 +1,10 @@
{
"name": "@salix/crud",
"version": "0.0.0",
"description": "",
"main": "index.js",
"repository": {
"type": "git",
"url": "http://git.verdnatura.es:/salix"
}
}

4
@salix/crud/src/crud.js Normal file
View File

@ -0,0 +1,4 @@
export * from './module';
export * from './customer/routes';
export {NAME as CUSTOMER_INDEX, COMPONENT as CUSTOMER_INDEX_COMPONENT} from './customer/index'

View File

@ -0,0 +1 @@
<div>index from component</div>

View File

@ -0,0 +1,14 @@
import template from './index.html';
import {module} from '../../module';
export const NAME = 'customerAdd';
export const COMPONENT = {
template: template,
controller: function() {
this.user = {name: 'world'};
}
};
module.component(NAME, COMPONENT);

View File

@ -0,0 +1,31 @@
import * as core from '@salix/core';
import * as index from './index';
core.module.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise("/");
$stateProvider
.state('index', {
url: "/index",
component: index.CUSTOMER_INDEX,
resolve:{
load:function(){
console.log('hello');
}
}
})
.state('add', {
url: "/add",
template: "<div>add</div>"
})
.state('edit', {
url: "/edit",
template: "<div>edit</div>"
})
.state('delete', {
url: "/delete",
template: "<div>delete</div>"
})
});

12
@salix/crud/src/module.js Normal file
View File

@ -0,0 +1,12 @@
import * as vendors from '@salix/vendor';
import * as core from '@salix/core';
//import {getModuleName,getVendorDependencies} from './util';
export const NAME = 'crud';
export const module = vendors.ng.module(NAME,[]);

View File

@ -2,5 +2,7 @@ import * as _angular from 'angular';
export const ng = { export const ng = {
module: _angular.module, module: _angular.module,
bootstrap: _angular.bootstrap bootstrap: _angular.bootstrap,
$$minErr :_angular.$$minErr,
angular:_angular
} }

View File

@ -0,0 +1,4 @@
import * as _materialdesignlite from 'material-design-lite';
import * as css from 'material-design-lite/material.min.css';
export const materialdesignlite = _materialdesignlite;

View File

@ -1,3 +1,4 @@
export * from './angular-vendor'; export * from './angular-vendor';
export * from './oclazyload-vendor'; export * from './oclazyload-vendor';
export * from './uirouter-vendor'; export * from './uirouter-vendor';
export * from './materialdesignlite-vendor';

View File

@ -1,12 +1,15 @@
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<title>Salix</title> <title>Salix</title>
</head> </head>
<body> <body>
<div id="app"> <div id="app">
{{1+1}} <div ui-view></div>
<a ui-sref="index">index</a>
<a ui-sref="add">add</a>
<a ui-sref="edit">edit</a>
<a ui-sref="delete">delete</a>
</div> </div>
<script type="text/javascript" src="build/salix.app.js" selector="#app"></script> <script type="text/javascript" src="build/salix.app.js" selector="#app"></script>
</body> </body>

View File

@ -1,26 +0,0 @@
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'run', 'dev' ]
2 info using npm@1.4.21
3 info using node@v4.4.7
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info predev salix-app@1.0.0
6 info dev salix-app@1.0.0
7 verbose unsafe-perm in lifecycle true
8 info salix-app@1.0.0 Failed to exec dev script
9 error salix-app@1.0.0 dev: `webpack --progress --colors --watch`
9 error Exit status 1
10 error Failed at the salix-app@1.0.0 dev script.
10 error This is most likely a problem with the salix-app package,
10 error not with npm itself.
10 error Tell the author that this fails on your system:
10 error webpack --progress --colors --watch
10 error You can get their info via:
10 error npm owner ls salix-app
10 error There is likely additional logging output above.
11 error System Linux 4.7.0-1-amd64
12 error command "/usr/bin/nodejs" "/usr/bin/npm" "run" "dev"
13 error cwd /home/juan/Proyectos/salix
14 error node -v v4.4.7
15 error npm -v 1.4.21
16 error code ELIFECYCLE
17 verbose exit [ 1, true ]

View File

@ -10,20 +10,23 @@
}, },
"dependencies": { "dependencies": {
"angular": "^1.5.8", "angular": "^1.5.8",
"angular-ui-router": "^0.3.1", "angular-ui-router": "^1.0.0-beta.3",
"oclazyload": "^1.0.9" "material-design-lite": "^1.2.1",
"oclazyload": "^0.6.3"
}, },
"devDependencies": { "devDependencies": {
"gulp": "^3.9.1",
"gulp-jsoncombine": "^1.0.3",
"webpack": "*", "webpack": "*",
"webpack-dev-server": "*", "webpack-dev-server": "*",
"babel-core": "*",
"babel-preset-es2015": "*",
"babel-loader": "*",
"raw-loader": "*", "raw-loader": "*",
"gulp": "^3.9.1", "css-loader": "^0.25.0",
"gulp-jsoncombine": "^1.0.3" "style-loader": "^0.13.1",
"babel-loader": "*",
"babel-core": "*",
"babel-preset-es2015": "*"
}, },
"scripts": { "scripts": {
"dev": "webpack --progress --colors --watch" "build": "webpack --progress --colors --watch"
} }
} }

View File

@ -28,6 +28,9 @@ module.exports =
},{ },{
test: /\.json$/, test: /\.json$/,
loader: 'json' loader: 'json'
},{
test: /\.css$/,
loader: 'style!css'
} }
] ]
}, },