mirror of
https://github.com/donpat1to/Schichtenplaner.git
synced 2025-11-30 22:45:46 +01:00
Compare commits
2 Commits
3ad497dd76
...
v1.0.10
| Author | SHA1 | Date | |
|---|---|---|---|
| cae2b83649 | |||
| a69e934075 |
@@ -65,7 +65,7 @@ export async function initializeDatabase(): Promise<void> {
|
|||||||
|
|
||||||
console.log('Existing tables found:', existingTables.map(t => t.name).join(', ') || 'none');
|
console.log('Existing tables found:', existingTables.map(t => t.name).join(', ') || 'none');
|
||||||
|
|
||||||
// UPDATED: Drop tables in correct dependency order for new schema
|
// Drop tables in correct dependency order for new schema
|
||||||
const tablesToDrop = [
|
const tablesToDrop = [
|
||||||
'employee_availability',
|
'employee_availability',
|
||||||
'shift_assignments',
|
'shift_assignments',
|
||||||
@@ -95,16 +95,40 @@ export async function initializeDatabase(): Promise<void> {
|
|||||||
// Continue with schema creation even if table dropping fails
|
// Continue with schema creation even if table dropping fails
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute schema creation in a transaction
|
// NEU: PRAGMA-Anweisungen außerhalb der Transaktion ausführen
|
||||||
await db.run('BEGIN EXCLUSIVE TRANSACTION');
|
console.log('Executing PRAGMA statements outside transaction...');
|
||||||
|
const pragmaStatements = schema
|
||||||
// Execute each statement separately for better error reporting
|
|
||||||
const statements = schema
|
|
||||||
.split(';')
|
.split(';')
|
||||||
.map(stmt => stmt.trim())
|
.map(stmt => stmt.trim())
|
||||||
.filter(stmt => stmt.length > 0)
|
.filter(stmt => stmt.length > 0)
|
||||||
|
.filter(stmt => stmt.toUpperCase().startsWith('PRAGMA'))
|
||||||
|
.map(stmt => {
|
||||||
|
return stmt.split('\n')
|
||||||
|
.filter(line => !line.trim().startsWith('--'))
|
||||||
|
.join('\n')
|
||||||
|
.trim();
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const statement of pragmaStatements) {
|
||||||
|
try {
|
||||||
|
console.log('Executing PRAGMA:', statement);
|
||||||
|
await db.run(statement);
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('PRAGMA statement might have failed:', statement, error);
|
||||||
|
// Continue even if PRAGMA fails
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schema-Erstellung in Transaktion
|
||||||
|
await db.run('BEGIN EXCLUSIVE TRANSACTION');
|
||||||
|
|
||||||
|
// Nur die CREATE TABLE und andere Anweisungen (ohne PRAGMA)
|
||||||
|
const schemaStatements = schema
|
||||||
|
.split(';')
|
||||||
|
.map(stmt => stmt.trim())
|
||||||
|
.filter(stmt => stmt.length > 0)
|
||||||
|
.filter(stmt => !stmt.toUpperCase().startsWith('PRAGMA'))
|
||||||
.map(stmt => {
|
.map(stmt => {
|
||||||
// Remove any single-line comments
|
|
||||||
return stmt.split('\n')
|
return stmt.split('\n')
|
||||||
.filter(line => !line.trim().startsWith('--'))
|
.filter(line => !line.trim().startsWith('--'))
|
||||||
.join('\n')
|
.join('\n')
|
||||||
@@ -112,7 +136,7 @@ export async function initializeDatabase(): Promise<void> {
|
|||||||
})
|
})
|
||||||
.filter(stmt => stmt.length > 0);
|
.filter(stmt => stmt.length > 0);
|
||||||
|
|
||||||
for (const statement of statements) {
|
for (const statement of schemaStatements) {
|
||||||
try {
|
try {
|
||||||
console.log('Executing statement:', statement.substring(0, 50) + '...');
|
console.log('Executing statement:', statement.substring(0, 50) + '...');
|
||||||
await db.run(statement);
|
await db.run(statement);
|
||||||
@@ -124,7 +148,7 @@ export async function initializeDatabase(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// UPDATED: Insert default data in correct order
|
// Insert default data in correct order
|
||||||
try {
|
try {
|
||||||
console.log('Inserting default employee types...');
|
console.log('Inserting default employee types...');
|
||||||
await db.run(`INSERT OR IGNORE INTO employee_types (type, category, has_contract_type) VALUES ('manager', 'internal', 1)`);
|
await db.run(`INSERT OR IGNORE INTO employee_types (type, category, has_contract_type) VALUES ('manager', 'internal', 1)`);
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ const useEmployeeForm = (mode: 'create' | 'edit', employee?: Employee) => {
|
|||||||
|
|
||||||
// Determine if can work alone based on employee type
|
// Determine if can work alone based on employee type
|
||||||
const canWorkAlone = employeeType === 'manager' ||
|
const canWorkAlone = employeeType === 'manager' ||
|
||||||
(employeeType === 'personell' && !formData.isTrainee);
|
(employeeType === 'personell' && !formData.isTrainee);
|
||||||
|
|
||||||
// Reset isTrainee if not personell
|
// Reset isTrainee if not personell
|
||||||
const isTrainee = employeeType === 'personell' ? formData.isTrainee : false;
|
const isTrainee = employeeType === 'personell' ? formData.isTrainee : false;
|
||||||
@@ -343,7 +343,8 @@ const useEmployeeForm = (mode: 'create' | 'edit', employee?: Employee) => {
|
|||||||
await executeWithValidation(() =>
|
await executeWithValidation(() =>
|
||||||
employeeService.changePassword(employee.id, {
|
employeeService.changePassword(employee.id, {
|
||||||
currentPassword: '',
|
currentPassword: '',
|
||||||
newPassword: passwordForm.newPassword
|
newPassword: passwordForm.newPassword,
|
||||||
|
confirmPassword: passwordForm.confirmPassword
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -365,8 +366,8 @@ const useEmployeeForm = (mode: 'create' | 'edit', employee?: Employee) => {
|
|||||||
switch (stepIndex) {
|
switch (stepIndex) {
|
||||||
case 0:
|
case 0:
|
||||||
return !!formData.firstname.trim() &&
|
return !!formData.firstname.trim() &&
|
||||||
!!formData.lastname.trim();
|
!!formData.lastname.trim();
|
||||||
// REMOVE: (mode === 'edit' || formData.password.length >= 6)
|
// REMOVE: (mode === 'edit' || formData.password.length >= 6)
|
||||||
case 1:
|
case 1:
|
||||||
return !!formData.employeeType;
|
return !!formData.employeeType;
|
||||||
case 2:
|
case 2:
|
||||||
@@ -711,7 +712,7 @@ const Step2Content: React.FC<StepContentProps> = ({
|
|||||||
{contractTypeOptions.map(contract => {
|
{contractTypeOptions.map(contract => {
|
||||||
const isFlexibleDisabled = contract.value === 'flexible' && formData.employeeType === 'personell';
|
const isFlexibleDisabled = contract.value === 'flexible' && formData.employeeType === 'personell';
|
||||||
const isSmallLargeDisabled = (contract.value === 'small' || contract.value === 'large') &&
|
const isSmallLargeDisabled = (contract.value === 'small' || contract.value === 'large') &&
|
||||||
(formData.employeeType === 'manager' || formData.employeeType === 'apprentice');
|
(formData.employeeType === 'manager' || formData.employeeType === 'apprentice');
|
||||||
const isDisabled = isFlexibleDisabled || isSmallLargeDisabled;
|
const isDisabled = isFlexibleDisabled || isSmallLargeDisabled;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -867,8 +868,8 @@ const Step3Content: React.FC<StepContentProps> = ({
|
|||||||
{formData.employeeType === 'manager'
|
{formData.employeeType === 'manager'
|
||||||
? 'Chefs sind automatisch als eigenständig markiert.'
|
? 'Chefs sind automatisch als eigenständig markiert.'
|
||||||
: formData.employeeType === 'personell' && formData.isTrainee
|
: formData.employeeType === 'personell' && formData.isTrainee
|
||||||
? 'Auszubildende können nicht als eigenständig markiert werden.'
|
? 'Auszubildende können nicht als eigenständig markiert werden.'
|
||||||
: 'Dieser Mitarbeiter kann komplexe Aufgaben eigenständig lösen und benötigt keine ständige Betreuung.'
|
: 'Dieser Mitarbeiter kann komplexe Aufgaben eigenständig lösen und benötigt keine ständige Betreuung.'
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user