Codis en alpha
This commit is contained in:
parent
6b3944277d
commit
b25dfe10aa
@ -7,6 +7,8 @@ import { CodisCollection } from '../api/codis';
|
|||||||
// import { TipusCollection } from '../api/tipus';
|
// import { TipusCollection } from '../api/tipus';
|
||||||
import { useSubscribe, useTracker, useFind } from 'meteor/react-meteor-data/suspense';
|
import { useSubscribe, useTracker, useFind } from 'meteor/react-meteor-data/suspense';
|
||||||
import { Roles } from 'meteor/roles';
|
import { Roles } from 'meteor/roles';
|
||||||
|
// import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
// import { useUserId } from 'meteor/react-meteor-accounts';
|
// import { useUserId } from 'meteor/react-meteor-accounts';
|
||||||
import Select from 'react-select';
|
import Select from 'react-select';
|
||||||
|
|
||||||
@ -112,10 +114,73 @@ export const Codis = () => {
|
|||||||
</>;
|
</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleToggleAbsActiu(ev) {
|
||||||
|
ev.preventDefault();
|
||||||
|
ev.stopPropagation();
|
||||||
|
|
||||||
|
if (codiSeleccionat) {
|
||||||
|
Meteor.callAsync('modCodiDocToggleAbsActiu', codiSeleccionat);
|
||||||
|
setCodiSeleccionat({
|
||||||
|
...codiSeleccionat,
|
||||||
|
absActiu: !codiSeleccionat.absActiu
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setConfecCodObj({
|
||||||
|
...confecCodObj,
|
||||||
|
absActiu: !confecCodObj.absActiu
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSetCondIni(v) {
|
||||||
|
|
||||||
|
console.log("h")
|
||||||
|
|
||||||
|
Meteor.callAsync('modCodiDocSetCondIni', {
|
||||||
|
...codiSeleccionat,
|
||||||
|
condIni: v.currentTarget.value
|
||||||
|
});
|
||||||
|
|
||||||
|
if (codiSeleccionat) {
|
||||||
|
setCodiSeleccionat({
|
||||||
|
...codiSeleccionat,
|
||||||
|
condIni: v.currentTarget.value
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setConfecCodObj({
|
||||||
|
...confecCodObj,
|
||||||
|
condIni: v.currentTarget.value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSetCondFi(v) {
|
||||||
|
|
||||||
|
Meteor.callAsync('modCodiDocSetCondFi', {
|
||||||
|
...codiSeleccionat,
|
||||||
|
condFi: v.currentTarget.value
|
||||||
|
});
|
||||||
|
|
||||||
|
if (codiSeleccionat) {
|
||||||
|
setCodiSeleccionat({
|
||||||
|
...codiSeleccionat,
|
||||||
|
condFi: v.currentTarget.value
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setConfecCodObj({
|
||||||
|
...confecCodObj,
|
||||||
|
condFi: v.currentTarget.value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const QuadreInfo_Codis = () => {
|
const QuadreInfo_Codis = () => {
|
||||||
|
|
||||||
|
// const navigate = useNavigate();
|
||||||
|
|
||||||
|
|
||||||
const [actCond, setActCond] = useState(true);
|
const [actCond, setActCond] = useState(true);
|
||||||
const [codiGenerat, setCodiGenerat] = useState(generaCodi());
|
// const [codiGenerat, setCodiGenerat] = useState(generaCodi());
|
||||||
|
|
||||||
const [absCond, setAbsCond] = useState('cond');
|
const [absCond, setAbsCond] = useState('cond');
|
||||||
|
|
||||||
@ -135,7 +200,6 @@ export const Codis = () => {
|
|||||||
|
|
||||||
<h1>Codis</h1>
|
<h1>Codis</h1>
|
||||||
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
fontWeight: `bolder`,
|
fontWeight: `bolder`,
|
||||||
@ -160,20 +224,26 @@ export const Codis = () => {
|
|||||||
action={d => {
|
action={d => {
|
||||||
try {
|
try {
|
||||||
Meteor.callAsync('editaOAfigCodi', {
|
Meteor.callAsync('editaOAfigCodi', {
|
||||||
...codiGenerat || [],
|
...confecCodObj || [],
|
||||||
codi: codiGenerat,
|
codi: confecCodObj.codi,
|
||||||
ambit: d.get('selAmbit') || "",
|
ambit: d.get('selAmbit') || "",
|
||||||
rol: d.get('selRol'),
|
rol: d.get('selRol'),
|
||||||
|
|
||||||
absCond,
|
absCond: d.get('absCond'),
|
||||||
absActiu: d.get('absActiu'),
|
absActiu: d.get('absActiu'),
|
||||||
condIni: d.get('condIni'),
|
condIni: d.get('condIni'),
|
||||||
condFi: d.get('condFi')
|
condFi: d.get('condFi')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
.then(() => setAmbitSeleccionat(null))
|
.then(() => setConfecCodObj({
|
||||||
|
codi: generaCodi(),
|
||||||
|
ambit: null,
|
||||||
|
rol: null,
|
||||||
|
absCond: "abs",
|
||||||
|
absActiu: false,
|
||||||
|
condIni: null,
|
||||||
|
condFi: null
|
||||||
|
}))
|
||||||
.catch(err => console.error(err))
|
.catch(err => console.error(err))
|
||||||
;
|
;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -255,7 +325,7 @@ export const Codis = () => {
|
|||||||
|
|
||||||
onChange={(ev) => {
|
onChange={(ev) => {
|
||||||
if (codiSeleccionat) {
|
if (codiSeleccionat) {
|
||||||
Meteor.callAsync('modActivacioAbsolutaCodi', codiSeleccionat);
|
Meteor.callAsync('modActivacioAbsCond', codiSeleccionat, 'abs');
|
||||||
setCodiSeleccionat({
|
setCodiSeleccionat({
|
||||||
...codiSeleccionat,
|
...codiSeleccionat,
|
||||||
absCond: 'abs'
|
absCond: 'abs'
|
||||||
@ -293,8 +363,10 @@ export const Codis = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onChange={(ev) => {
|
onChange={(ev) => {
|
||||||
|
// console.log("ev: ", ev);
|
||||||
|
|
||||||
if (codiSeleccionat) {
|
if (codiSeleccionat) {
|
||||||
Meteor.callAsync('modActivacioAbsolutaCodi', codiSeleccionat);
|
Meteor.callAsync('modActivacioAbsCond', codiSeleccionat, 'cond');
|
||||||
setCodiSeleccionat({
|
setCodiSeleccionat({
|
||||||
...codiSeleccionat,
|
...codiSeleccionat,
|
||||||
absCond: 'cond'
|
absCond: 'cond'
|
||||||
@ -341,22 +413,7 @@ export const Codis = () => {
|
|||||||
id="absActiu"
|
id="absActiu"
|
||||||
{...codSelAbsActChecked}
|
{...codSelAbsActChecked}
|
||||||
onChange={ev => {
|
onChange={ev => {
|
||||||
ev.preventDefault();
|
handleToggleAbsActiu(ev);
|
||||||
ev.stopPropagation();
|
|
||||||
|
|
||||||
if (codiSeleccionat) {
|
|
||||||
Meteor.callAsync('modActivacioAbsolutaCodi', codiSeleccionat);
|
|
||||||
setCodiSeleccionat({
|
|
||||||
...codiSeleccionat,
|
|
||||||
absActiu: !codiSeleccionat.absActiu
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setConfecCodObj({
|
|
||||||
...confecCodObj,
|
|
||||||
absActiu: !confecCodObj.absActiu
|
|
||||||
});
|
|
||||||
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
@ -387,28 +444,31 @@ export const Codis = () => {
|
|||||||
name="condIni"
|
name="condIni"
|
||||||
onChange={v => {
|
onChange={v => {
|
||||||
|
|
||||||
// console.log("dataIni: ", v.currentTarget.value);
|
// // console.log("dataIni: ", v.currentTarget.value);
|
||||||
setConfecCodObj({
|
// setConfecCodObj({
|
||||||
...confecCodObj,
|
// ...confecCodObj,
|
||||||
condIni: v.currentTarget.value
|
// condIni: v.currentTarget.value
|
||||||
})
|
// })
|
||||||
|
|
||||||
|
handleSetCondIni(v);
|
||||||
}}
|
}}
|
||||||
defaultValue={confecCodObj.condIni}
|
defaultValue={codiSeleccionat?.condIni || confecCodObj.condIni}
|
||||||
/>
|
/>
|
||||||
<br />
|
<br />
|
||||||
Fins a: <input
|
Fins a: <input
|
||||||
required={confecCodObj.
|
required={confecCodObj.actCond === 'cond'}
|
||||||
actCond === 'cond'}
|
|
||||||
type="date"
|
type="date"
|
||||||
name="condFi"
|
name="condFi"
|
||||||
onChange={v => {
|
onChange={v => {
|
||||||
// console.log("dataFi: ", v.currentTarget.value);
|
// console.log("dataFi: ", v.currentTarget.value);
|
||||||
setConfecCodObj({
|
// setConfecCodObj({
|
||||||
...confecCodObj,
|
// ...confecCodObj,
|
||||||
condFi: v.currentTarget.value
|
// condFi: v.currentTarget.value
|
||||||
})
|
// })
|
||||||
|
|
||||||
|
handleSetCondFi(v);
|
||||||
}}
|
}}
|
||||||
defaultValue={confecCodObj.condFi}
|
defaultValue={codiSeleccionat?.condFi || confecCodObj.condFi}
|
||||||
/>
|
/>
|
||||||
<br />
|
<br />
|
||||||
</>
|
</>
|
||||||
@ -416,7 +476,7 @@ export const Codis = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type='submit' value="Donar d'alta el codi" />
|
{!codiSeleccionat && <input type='submit' value="Donar d'alta el codi" />}
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>;
|
</div>;
|
||||||
@ -474,13 +534,11 @@ export const Codis = () => {
|
|||||||
backgroundColor: `${cod.absActiu ? "lime" : "red"}`
|
backgroundColor: `${cod.absActiu ? "lime" : "red"}`
|
||||||
}}
|
}}
|
||||||
onClick={ev => {
|
onClick={ev => {
|
||||||
ev.preventDefault();
|
handleToggleAbsActiu(ev);
|
||||||
ev.stopPropagation();
|
|
||||||
|
|
||||||
Meteor.callAsync('modActivacioAbsolutaCodi', cod);
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{cod.codi}
|
<div>{cod.codi}</div>
|
||||||
|
<div>{}</div>
|
||||||
|
|
||||||
</li>)
|
</li>)
|
||||||
}</ul>
|
}</ul>
|
||||||
|
|||||||
@ -515,9 +515,9 @@ Meteor.methods({
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
'modActivacioAbsolutaCodi': async function (cod) {
|
'modCodiDocToggleAbsActiu': async function (cod) {
|
||||||
|
|
||||||
console.log("modActivacioAbsolutaCodi: ", cod);
|
console.log("modCodiDocToggleAbsActiu: ", cod);
|
||||||
|
|
||||||
return await CodisCollection.updateAsync(
|
return await CodisCollection.updateAsync(
|
||||||
{ _id: cod._id },
|
{ _id: cod._id },
|
||||||
@ -525,8 +525,47 @@ Meteor.methods({
|
|||||||
...cod,
|
...cod,
|
||||||
absActiu: !cod.absActiu
|
absActiu: !cod.absActiu
|
||||||
}}
|
}}
|
||||||
)
|
);
|
||||||
}
|
},
|
||||||
|
|
||||||
|
'modActivacioAbsCond': async function (cod, absCond) {
|
||||||
|
|
||||||
|
console.log("modActivacioAbsCond: ", cod, absCond);
|
||||||
|
|
||||||
|
return await CodisCollection.updateAsync(
|
||||||
|
{ _id: cod._id },
|
||||||
|
{ $set: {
|
||||||
|
...cod,
|
||||||
|
absCond
|
||||||
|
}}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
'modCodiDocSetCondIni': async function (cod) {
|
||||||
|
|
||||||
|
console.log("modCodiDocSetCondIni: ", cod);
|
||||||
|
|
||||||
|
return await CodisCollection.updateAsync(
|
||||||
|
{ _id: cod._id },
|
||||||
|
{ $set: {
|
||||||
|
...cod,
|
||||||
|
condIni: cod.condIni
|
||||||
|
}}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
'modCodiDocSetCondFi': async function (cod) {
|
||||||
|
|
||||||
|
console.log("modCodiDocSetCondFi: ", cod);
|
||||||
|
|
||||||
|
return await CodisCollection.updateAsync(
|
||||||
|
{ _id: cod._id },
|
||||||
|
{ $set: {
|
||||||
|
...cod,
|
||||||
|
condFi: cod.condFi
|
||||||
|
}}
|
||||||
|
);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
Loading…
Reference in New Issue
Block a user