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 { useSubscribe, useTracker, useFind } from 'meteor/react-meteor-data/suspense';
|
||||
import { Roles } from 'meteor/roles';
|
||||
// import { useNavigate } from 'react-router-dom';
|
||||
|
||||
// import { useUserId } from 'meteor/react-meteor-accounts';
|
||||
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 navigate = useNavigate();
|
||||
|
||||
|
||||
const [actCond, setActCond] = useState(true);
|
||||
const [codiGenerat, setCodiGenerat] = useState(generaCodi());
|
||||
// const [codiGenerat, setCodiGenerat] = useState(generaCodi());
|
||||
|
||||
const [absCond, setAbsCond] = useState('cond');
|
||||
|
||||
@ -135,7 +200,6 @@ export const Codis = () => {
|
||||
|
||||
<h1>Codis</h1>
|
||||
|
||||
|
||||
<div
|
||||
style={{
|
||||
fontWeight: `bolder`,
|
||||
@ -160,20 +224,26 @@ export const Codis = () => {
|
||||
action={d => {
|
||||
try {
|
||||
Meteor.callAsync('editaOAfigCodi', {
|
||||
...codiGenerat || [],
|
||||
codi: codiGenerat,
|
||||
...confecCodObj || [],
|
||||
codi: confecCodObj.codi,
|
||||
ambit: d.get('selAmbit') || "",
|
||||
rol: d.get('selRol'),
|
||||
|
||||
absCond,
|
||||
absCond: d.get('absCond'),
|
||||
absActiu: d.get('absActiu'),
|
||||
condIni: d.get('condIni'),
|
||||
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) {
|
||||
@ -255,7 +325,7 @@ export const Codis = () => {
|
||||
|
||||
onChange={(ev) => {
|
||||
if (codiSeleccionat) {
|
||||
Meteor.callAsync('modActivacioAbsolutaCodi', codiSeleccionat);
|
||||
Meteor.callAsync('modActivacioAbsCond', codiSeleccionat, 'abs');
|
||||
setCodiSeleccionat({
|
||||
...codiSeleccionat,
|
||||
absCond: 'abs'
|
||||
@ -293,8 +363,10 @@ export const Codis = () => {
|
||||
}
|
||||
|
||||
onChange={(ev) => {
|
||||
// console.log("ev: ", ev);
|
||||
|
||||
if (codiSeleccionat) {
|
||||
Meteor.callAsync('modActivacioAbsolutaCodi', codiSeleccionat);
|
||||
Meteor.callAsync('modActivacioAbsCond', codiSeleccionat, 'cond');
|
||||
setCodiSeleccionat({
|
||||
...codiSeleccionat,
|
||||
absCond: 'cond'
|
||||
@ -341,22 +413,7 @@ export const Codis = () => {
|
||||
id="absActiu"
|
||||
{...codSelAbsActChecked}
|
||||
onChange={ev => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
if (codiSeleccionat) {
|
||||
Meteor.callAsync('modActivacioAbsolutaCodi', codiSeleccionat);
|
||||
setCodiSeleccionat({
|
||||
...codiSeleccionat,
|
||||
absActiu: !codiSeleccionat.absActiu
|
||||
});
|
||||
}
|
||||
|
||||
setConfecCodObj({
|
||||
...confecCodObj,
|
||||
absActiu: !confecCodObj.absActiu
|
||||
});
|
||||
|
||||
handleToggleAbsActiu(ev);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
@ -373,7 +430,7 @@ export const Codis = () => {
|
||||
&&
|
||||
codiSeleccionat?.absCond !== 'abs'
|
||||
&&
|
||||
|
||||
|
||||
<>
|
||||
<p
|
||||
style={{
|
||||
@ -387,28 +444,31 @@ export const Codis = () => {
|
||||
name="condIni"
|
||||
onChange={v => {
|
||||
|
||||
// console.log("dataIni: ", v.currentTarget.value);
|
||||
setConfecCodObj({
|
||||
...confecCodObj,
|
||||
condIni: v.currentTarget.value
|
||||
})
|
||||
// // console.log("dataIni: ", v.currentTarget.value);
|
||||
// setConfecCodObj({
|
||||
// ...confecCodObj,
|
||||
// condIni: v.currentTarget.value
|
||||
// })
|
||||
|
||||
handleSetCondIni(v);
|
||||
}}
|
||||
defaultValue={confecCodObj.condIni}
|
||||
defaultValue={codiSeleccionat?.condIni || confecCodObj.condIni}
|
||||
/>
|
||||
<br />
|
||||
Fins a: <input
|
||||
required={confecCodObj.
|
||||
actCond === 'cond'}
|
||||
required={confecCodObj.actCond === 'cond'}
|
||||
type="date"
|
||||
name="condFi"
|
||||
onChange={v => {
|
||||
// console.log("dataFi: ", v.currentTarget.value);
|
||||
setConfecCodObj({
|
||||
...confecCodObj,
|
||||
condFi: v.currentTarget.value
|
||||
})
|
||||
// setConfecCodObj({
|
||||
// ...confecCodObj,
|
||||
// condFi: v.currentTarget.value
|
||||
// })
|
||||
|
||||
handleSetCondFi(v);
|
||||
}}
|
||||
defaultValue={confecCodObj.condFi}
|
||||
defaultValue={codiSeleccionat?.condFi || confecCodObj.condFi}
|
||||
/>
|
||||
<br />
|
||||
</>
|
||||
@ -416,7 +476,7 @@ export const Codis = () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type='submit' value="Donar d'alta el codi" />
|
||||
{!codiSeleccionat && <input type='submit' value="Donar d'alta el codi" />}
|
||||
|
||||
</form>
|
||||
</div>;
|
||||
@ -474,13 +534,11 @@ export const Codis = () => {
|
||||
backgroundColor: `${cod.absActiu ? "lime" : "red"}`
|
||||
}}
|
||||
onClick={ev => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
Meteor.callAsync('modActivacioAbsolutaCodi', cod);
|
||||
handleToggleAbsActiu(ev);
|
||||
}}
|
||||
/>
|
||||
{cod.codi}
|
||||
<div>{cod.codi}</div>
|
||||
<div>{}</div>
|
||||
|
||||
</li>)
|
||||
}</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(
|
||||
{ _id: cod._id },
|
||||
@ -525,8 +525,47 @@ Meteor.methods({
|
||||
...cod,
|
||||
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